Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,16 +21,7 @@ labels = categories.readline().split(";")
|
|
21 |
radio = gr.inputs.Radio(models_name, default="DenseNet", type="value")
|
22 |
|
23 |
def predict_image(image, model_name):
|
24 |
-
|
25 |
-
|
26 |
-
print("======================")
|
27 |
-
print(type(image))
|
28 |
-
print(type(model_name))
|
29 |
-
print("==========")
|
30 |
-
print(image)
|
31 |
-
print(model_name)
|
32 |
-
print("======================")
|
33 |
-
|
34 |
if model_name == "DenseNet":
|
35 |
image = np.array(image) / 255
|
36 |
image = np.expand_dims(image, axis=0)
|
@@ -39,8 +30,9 @@ def predict_image(image, model_name):
|
|
39 |
pred = model.predict(image)
|
40 |
|
41 |
pred = dict((labels[i], "%.2f" % pred[0][i]) for i in range(len(labels)))
|
42 |
-
else:
|
43 |
|
|
|
|
|
44 |
image = Image.fromarray(np.uint8(image)).convert('RGB')
|
45 |
classifier = TorchVisionClassifierInference(
|
46 |
model_path = "./models/" + model_name
|
@@ -58,7 +50,7 @@ def predict_image(image, model_name):
|
|
58 |
image = gr.inputs.Image(shape=(300, 300), label="Upload Your Image Here")
|
59 |
label = gr.outputs.Label(num_top_classes=len(labels))
|
60 |
|
61 |
-
samples = [["samples/" + p + ".jpg"] for p in labels]
|
62 |
|
63 |
interface = gr.Interface(
|
64 |
fn=predict_image,
|
|
|
21 |
radio = gr.inputs.Radio(models_name, default="DenseNet", type="value")
|
22 |
|
23 |
def predict_image(image, model_name):
|
24 |
+
# model create by keras
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
if model_name == "DenseNet":
|
26 |
image = np.array(image) / 255
|
27 |
image = np.expand_dims(image, axis=0)
|
|
|
30 |
pred = model.predict(image)
|
31 |
|
32 |
pred = dict((labels[i], "%.2f" % pred[0][i]) for i in range(len(labels)))
|
|
|
33 |
|
34 |
+
# model create by HugsVision
|
35 |
+
else:
|
36 |
image = Image.fromarray(np.uint8(image)).convert('RGB')
|
37 |
classifier = TorchVisionClassifierInference(
|
38 |
model_path = "./models/" + model_name
|
|
|
50 |
image = gr.inputs.Image(shape=(300, 300), label="Upload Your Image Here")
|
51 |
label = gr.outputs.Label(num_top_classes=len(labels))
|
52 |
|
53 |
+
samples = [["samples/" + p + ".jpg", p] for p in labels]
|
54 |
|
55 |
interface = gr.Interface(
|
56 |
fn=predict_image,
|