Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from typing import Any | |
| from fastai.vision.all import load_learner | |
| learn = load_learner("assets/model.pkl") | |
| CATEGORIES = ("azurite", "copper", "malachite") | |
| def classify(input_image: Any) -> gr.Label: | |
| pred, idx, probs = learn.predict(input_image) | |
| return input_image, dict(zip(CATEGORIES, map(float, probs))) | |
| demo = gr.Interface( | |
| fn=classify, | |
| inputs=gr.Image( | |
| label="Upload mineral", | |
| sources=["upload", "webcam"], | |
| height=224, | |
| width=224, | |
| type="pil", | |
| ), | |
| outputs=[ | |
| gr.Image(label="Processed Image"), | |
| gr.Label(label="Result"), | |
| ], | |
| title="What ore is this?", | |
| examples=[ | |
| "assets/malachite.jpeg", | |
| "assets/azurite.jpeg", | |
| "assets/copper.jpeg", | |
| ], | |
| ) | |
| demo.launch() | |