Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -97,21 +97,15 @@ async def process_file(file_data: FileProcess):
|
|
97 |
|
98 |
|
99 |
def process_video(video_path):
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
confidences = {label: float(probs[i]) for i, label in enumerate(class_dict)}
|
108 |
-
|
109 |
-
# If classification is not formal, return 'informal'
|
110 |
-
if classification != 'formal':
|
111 |
-
informal_confidence = sum(confidences[label] for label in class_dict if label != 'formal')
|
112 |
-
return {'informal': informal_confidence}
|
113 |
-
else:
|
114 |
-
return {'formal': confidences['formal']}
|
115 |
|
116 |
|
117 |
if __name__ == "__main__":
|
|
|
97 |
|
98 |
|
99 |
def process_video(video_path):
|
100 |
+
learn = load_learner('model.pkl')
|
101 |
+
searches = ['formal','casual','athletic']
|
102 |
+
searches = sorted(searches) # need to be sorted because that's the order the predictions will be outputed
|
103 |
+
values = [i for i in range(0,len(searches))]
|
104 |
+
class_dict = dict(zip(searches,values))
|
105 |
+
|
106 |
+
classication,_,probs = learn.predict(im)
|
107 |
+
confidences = {label: float(probs[i]) for i, label in enumerate(class_dict)}
|
108 |
+
return confidences
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
|
111 |
if __name__ == "__main__":
|