Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from fastai.learner import load_learner | |
| import requests | |
| import pathlib | |
| pathlib.WindowsPath = pathlib.PosixPath | |
| learner = load_learner('model.pkl') | |
| st.markdown('# Wolf/Dog Detector') | |
| img_url = st.text_input('URL to image: ') | |
| if img_url: | |
| img_data = requests.get(img_url).content | |
| try: | |
| label, _, pred = learner.predict(img_data) | |
| index = 0 if label == 'dog' else 1 | |
| st.markdown(f'## Detected a:') | |
| st.markdown(f'### {label}') | |
| st.write(f'Confidence of being a {label}: {pred[index]*100:.2f}%') | |
| st.image(img_data) | |
| except: | |
| st.write('Could not find image. Try another link.') | |