Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,17 +4,26 @@ from fastai import *
|
|
| 4 |
import torch
|
| 5 |
import os
|
| 6 |
from PIL import Image
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
model_path = 'multi_target_resnet34.pkl'
|
|
|
|
|
|
|
| 11 |
|
| 12 |
model = load_learner(model_path)
|
| 13 |
|
| 14 |
def result(path):
|
| 15 |
pred,_,probability = model.predict(path)
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
path = 'test images/'
|
|
|
|
| 4 |
import torch
|
| 5 |
import os
|
| 6 |
from PIL import Image
|
| 7 |
+
import pandas as pd
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
model_path = 'multi_target_resnet34.pkl'
|
| 12 |
+
helper_csv = 'info.csv'
|
| 13 |
+
df = pd.read_csv(helper_csv)
|
| 14 |
|
| 15 |
model = load_learner(model_path)
|
| 16 |
|
| 17 |
def result(path):
|
| 18 |
pred,_,probability = model.predict(path)
|
| 19 |
+
arr = ['Species','Scientific Name','Name','Habitat','Color','Found_In','Diet']
|
| 20 |
+
vals = ['','','','','','','','']
|
| 21 |
+
for x in pred:
|
| 22 |
+
val = df[df['columns'] == x]['values']
|
| 23 |
+
ind = arr.find(val)
|
| 24 |
+
vals[ind] = x
|
| 25 |
+
|
| 26 |
+
return f'{arr}-->{vals}'
|
| 27 |
|
| 28 |
|
| 29 |
path = 'test images/'
|