Spaces:
Sleeping
Sleeping
weights to folder
Browse files- app.py +7 -3
- requirements.txt +2 -2
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
import sys
|
| 4 |
import zipfile
|
| 5 |
from fastai import *
|
|
@@ -9,6 +9,7 @@ import os
|
|
| 9 |
import timm
|
| 10 |
from timm import create_model
|
| 11 |
from fastai.vision.all import *
|
|
|
|
| 12 |
|
| 13 |
torch.device('cpu')
|
| 14 |
def seed_everything(seed):
|
|
@@ -46,9 +47,12 @@ file_name = st.file_uploader("Upload a hot dog candidate image")
|
|
| 46 |
if file_name is not None:
|
| 47 |
col1, col2 = st.columns(2)
|
| 48 |
|
|
|
|
| 49 |
image = Image.open(file_name)
|
|
|
|
|
|
|
| 50 |
col1.image(image, use_column_width=True)
|
| 51 |
-
pred = catanddog.predict(
|
| 52 |
print(pred)
|
| 53 |
def metric_rmse(input,target):
|
| 54 |
return 100*torch.sqrt(F.mse_loss(F.sigmoid(input.flatten()), target))
|
|
@@ -65,4 +69,4 @@ if file_name is not None:
|
|
| 65 |
print(pred)
|
| 66 |
print("Score for this catto:", min(int(pred[2] * 100 + 35), 100))
|
| 67 |
col2.header("Probabilities")
|
| 68 |
-
col2.subheader(f"{ pred[2] }: { round(pred[2] * 100, 1)}%")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import PIL
|
| 3 |
import sys
|
| 4 |
import zipfile
|
| 5 |
from fastai import *
|
|
|
|
| 9 |
import timm
|
| 10 |
from timm import create_model
|
| 11 |
from fastai.vision.all import *
|
| 12 |
+
import torchvision.transforms as T
|
| 13 |
|
| 14 |
torch.device('cpu')
|
| 15 |
def seed_everything(seed):
|
|
|
|
| 47 |
if file_name is not None:
|
| 48 |
col1, col2 = st.columns(2)
|
| 49 |
|
| 50 |
+
|
| 51 |
image = Image.open(file_name)
|
| 52 |
+
print(image)
|
| 53 |
+
img_fastai = np.array(image)
|
| 54 |
col1.image(image, use_column_width=True)
|
| 55 |
+
pred = catanddog.predict(img_fastai)[1]
|
| 56 |
print(pred)
|
| 57 |
def metric_rmse(input,target):
|
| 58 |
return 100*torch.sqrt(F.mse_loss(F.sigmoid(input.flatten()), target))
|
|
|
|
| 69 |
print(pred)
|
| 70 |
print("Score for this catto:", min(int(pred[2] * 100 + 35), 100))
|
| 71 |
col2.header("Probabilities")
|
| 72 |
+
col2.subheader(f"{ pred[2] }: { round(float(pred[2]) * 100, 1)}%")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
timm
|
| 2 |
torch
|
| 3 |
-
fastai
|
|
|
|
|
|
|
|
|
| 1 |
torch
|
| 2 |
+
fastai
|
| 3 |
+
timm==0.6.5
|