Spaces:
Runtime error
Runtime error
test
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ with open(output_path,'r') as file:
|
|
| 18 |
LABELS = [x.strip() for x in file.readlines()]
|
| 19 |
|
| 20 |
num_classes = 4000
|
| 21 |
-
IMG_SIZE =
|
| 22 |
|
| 23 |
def _normalize_img(img):
|
| 24 |
img = tf.cast(img, tf.float32)/255. # All images will be rescaled by 1./255
|
|
@@ -35,10 +35,9 @@ def predict_fn(img):
|
|
| 35 |
temp = model.predict(x)
|
| 36 |
|
| 37 |
idx = np.argsort(np.squeeze(temp))[::-1]
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
-
return {
|
| 42 |
-
|
| 43 |
|
| 44 |
gr.Interface(predict_fn, gr.Image(type='pil'), outputs='label', examples=path,).launch()
|
|
|
|
| 18 |
LABELS = [x.strip() for x in file.readlines()]
|
| 19 |
|
| 20 |
num_classes = 4000
|
| 21 |
+
IMG_SIZE = 400
|
| 22 |
|
| 23 |
def _normalize_img(img):
|
| 24 |
img = tf.cast(img, tf.float32)/255. # All images will be rescaled by 1./255
|
|
|
|
| 35 |
temp = model.predict(x)
|
| 36 |
|
| 37 |
idx = np.argsort(np.squeeze(temp))[::-1]
|
| 38 |
+
top3_value = np.asarray([temp[0][i] for i in idx[0:3]])
|
| 39 |
+
top3_idx = idx[0:3]
|
| 40 |
|
| 41 |
+
return {LABELS[i]:str(v) for i,v in zip(top3_idx,top3_value)}
|
|
|
|
| 42 |
|
| 43 |
gr.Interface(predict_fn, gr.Image(type='pil'), outputs='label', examples=path,).launch()
|