Spaces:
Sleeping
Sleeping
Download app.py from Samee-ul-haq/Hydration-Check: direct link, hf CLI and curl.
- Browser
- Download file 623 Bytes
-
https://huggingface.co/spaces/Samee-ul-haq/Hydration-Check/resolve/main/app.py
- Command line
-
hf download hf://spaces/Samee-ul-haq/Hydration-Check/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Samee-ul-haq/Hydration-Check/resolve/main/app.py
623 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| # 1. Load the model | |
| learn = load_learner('hydration_model.pkl') | |
| # 2. Get the labels from the model automatically | |
| categories = learn.dls.vocab | |
| # 3. Define the function | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| # 4. Build the interface | |
| image = gr.Image(type="pil") # Allow uploading or taking a photo | |
| label = gr.Label() | |
| examples = [] # You can add example filenames here later if you upload images | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label) | |
| intf.launch(inline=False) |