Dimitre commited on
Commit
1627a17
·
1 Parent(s): 0277979

Adding TF req

Browse files
Files changed (2) hide show
  1. app.py +8 -8
  2. requirements.txt +2 -1
app.py CHANGED
@@ -7,10 +7,10 @@ sys.path.append("/hub")
7
  import gradio as gr
8
  from hub.tensorflow_hub.hf_utils import pull_from_hub
9
 
10
- # import requests
11
- # # Download human-readable labels for ImageNet.
12
- # response = requests.get("https://storage.googleapis.com/download.tensorflow.org/data/ImageNetLabels.txt")
13
- # labels = [x for x in response.text.split("\n") if x != ""]
14
 
15
  model = pull_from_hub(repo_id="Dimitre/mobilenet_v3_small")
16
 
@@ -23,14 +23,14 @@ def preprocess(image):
23
  print(image / 255.)
24
  return image / 255.
25
 
26
- # def postprocess(prediction):
27
- # return {labels[i]: prediction[i] for i in range(len(labels))}
28
 
29
  def predict_fn(image):
30
  image = preprocess(image)
31
  prediction = model([image])
32
- # scores = postprocess(prediction)
33
- return prediction
34
 
35
  iface = gr.Interface(fn=predict_fn,
36
  inputs=gr.Image(shape=(224, 224)),
 
7
  import gradio as gr
8
  from hub.tensorflow_hub.hf_utils import pull_from_hub
9
 
10
+ import requests
11
+ # Download human-readable labels for ImageNet.
12
+ response = requests.get("https://storage.googleapis.com/download.tensorflow.org/data/ImageNetLabels.txt")
13
+ labels = [x for x in response.text.split("\n") if x != ""]
14
 
15
  model = pull_from_hub(repo_id="Dimitre/mobilenet_v3_small")
16
 
 
23
  print(image / 255.)
24
  return image / 255.
25
 
26
+ def postprocess(prediction):
27
+ return {labels[i]: prediction[i] for i in range(len(labels))}
28
 
29
  def predict_fn(image):
30
  image = preprocess(image)
31
  prediction = model([image])
32
+ scores = postprocess(prediction)
33
+ return scores
34
 
35
  iface = gr.Interface(fn=predict_fn,
36
  inputs=gr.Image(shape=(224, 224)),
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- GitPython
 
 
1
+ GitPython
2
+ tensorflow