Spaces:
Sleeping
Sleeping
Upload 7 files
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ effnetb2.load_state_dict(
|
|
19 |
f="09_pretrained_effnetb2_feature_extractor_pizza_steak_sushi_20_percent.pth",
|
20 |
map_location=torch.device("cpu") # load the model to the CPU
|
21 |
)
|
22 |
-
)
|
23 |
### Predict function
|
24 |
|
25 |
def predict(img) -> Tuple[Dict, float]:
|
@@ -47,7 +47,7 @@ def predict(img) -> Tuple[Dict, float]:
|
|
47 |
|
48 |
## 4. Gradio app
|
49 |
|
50 |
-
# Create title, description and article.
|
51 |
title = "FoodVision Mini ππ₯©π£"
|
52 |
description = "An [EfficientNetB2 feature extractor](https://pytorch.org/vision/stable/models/generated/torchvision.models.efficientnet_b2.html#torchvision.models.efficientnet_b2) computer vision model to classify images as pizza, steak or sushi."
|
53 |
article = "Created at [09. PyTorch Model Deployment](https://www.learnpytorch.io/09_pytorch_model_deployment/#74-building-a-gradio-interface)."
|
@@ -56,14 +56,14 @@ article = "Created at [09. PyTorch Model Deployment](https://www.learnpytorch.io
|
|
56 |
example_list = [["examples/" + example] for exmple in os.listdir("examples")]
|
57 |
|
58 |
# Create the Gradio demo
|
59 |
-
demo = gr.Interface(fn=predict,
|
60 |
-
inputs=gr.Image(type=
|
61 |
outputs=[gr.Label(num_top_classes=3, label="Predictions"),
|
62 |
gr.Number(label="Prediction time (s)")],
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
# Launch the demo!
|
69 |
demo.launch()
|
|
|
19 |
f="09_pretrained_effnetb2_feature_extractor_pizza_steak_sushi_20_percent.pth",
|
20 |
map_location=torch.device("cpu") # load the model to the CPU
|
21 |
)
|
22 |
+
)
|
23 |
### Predict function
|
24 |
|
25 |
def predict(img) -> Tuple[Dict, float]:
|
|
|
47 |
|
48 |
## 4. Gradio app
|
49 |
|
50 |
+
# Create title, description and article.
|
51 |
title = "FoodVision Mini ππ₯©π£"
|
52 |
description = "An [EfficientNetB2 feature extractor](https://pytorch.org/vision/stable/models/generated/torchvision.models.efficientnet_b2.html#torchvision.models.efficientnet_b2) computer vision model to classify images as pizza, steak or sushi."
|
53 |
article = "Created at [09. PyTorch Model Deployment](https://www.learnpytorch.io/09_pytorch_model_deployment/#74-building-a-gradio-interface)."
|
|
|
56 |
example_list = [["examples/" + example] for exmple in os.listdir("examples")]
|
57 |
|
58 |
# Create the Gradio demo
|
59 |
+
demo = gr.Interface(fn=predict, # maps inputs to outputs
|
60 |
+
inputs=gr.Image(type=pil"),
|
61 |
outputs=[gr.Label(num_top_classes=3, label="Predictions"),
|
62 |
gr.Number(label="Prediction time (s)")],
|
63 |
+
examples=example_list,
|
64 |
+
title-title,
|
65 |
+
description=description,
|
66 |
+
article=article)
|
67 |
+
|
68 |
# Launch the demo!
|
69 |
demo.launch()
|