Skip to content

luisccastillo/image-classifier

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tf-image-classifier

Trusted execution tensorflow application that protects the prediction model of a classification program.

input

  • The mobilenetv1.h5 keras model
  • The image classes index file
{"0": ["n01440764", "tench"], 
"1": ["n01443537", "goldfish"], 
"2": ["n01484850", "great_white_shark"],
"3": ["n01491361", "tiger_shark"], 
"4": ["n01494475", "hammerhead"]
...}
  • The images to be classified

bridge.jpg mountain.jpg

Use 224 x 224 images for better results, examples can be found here https://picsum.photos/224 otherwise, the images will be resized automatically. The program reads only files ending in .jpg or .JPG

output

the classified files and their scores :

{
	"0": {
		"filename": "bridge.jpg",
		"predictions": {
			"0": {
				"class": "n04366367",
				"description": "suspension_bridge",
				"score": 0.9888280630111694
			},
			"1": {
				"class": "n03933933",
				"description": "pier",
				"score": 0.0090409554541111
			},
			"2": {
				"class": "n03947888",
				"description": "pirate",
				"score": 0.0017763386713340878
			},
			"3": {
				"class": "n04147183",
				"description": "schooner",
				"score": 0.0001802647893782705
			},
			"4": {
				"class": "n04311004",
				"description": "steel_arch_bridge",
				"score": 0.0001498213387094438
			}
		}
	},
	"1": {
		"filename": "mountain.jpg",
		"predictions": {
			"0": {
				"class": "n09193705",
				"description": "alp",
				"score": 0.16904009878635406
			},
			"1": {
				"class": "n04008634",
				"description": "projectile",
				"score": 0.13410575687885284
			},
			"2": {
				"class": "n02951358",
				"description": "canoe",
				"score": 0.09152363240718842
			},
			"3": {
				"class": "n09332890",
				"description": "lakeside",
				"score": 0.0898909792304039
			},
			"4": {
				"class": "n09468604",
				"description": "valley",
				"score": 0.08329412341117859
			}
		}
	}
}

Running locally

docker run --rm -v ${PWD}/local_run:/iexec_out -e IEXEC_OUT=/iexec_out \
-v ${PWD}/local_run:/iexec_in -e IEXEC_IN=/iexec_in \
-e IEXEC_DATASET_FILENAME=mobilenetv1.h5 tf-image-classifier:latest

Running in iExec

Considering the image has been sconified, app deployed and dataset encrypted and deployed

iexec app run 0x... \
--tag tee --dataset 0xa9ed83C91D8311A2B52A6f5efd5A3196D635f53D \
--workerpool 0x5210cD9C57546159Ac60DaC17B3e6cDF48674FBD \
--chain viviani --input-files \
https://raw.githubusercontent.com/iExecBlockchainComputing/image-classifier/main/local_run/bridge.jpg,https://raw.githubusercontent.com/iExecBlockchainComputing/image-classifier/main/local_run/mountain.jpg,https://raw.githubusercontent.com/iExecBlockchainComputing/image-classifier/main/local_run/imagenet_class_index.json

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 62.9%
  • Shell 24.8%
  • Dockerfile 12.3%