Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -97,7 +97,7 @@ def predict_emotion(frame):
|
|
97 |
frame = predict_image(frame)
|
98 |
else:
|
99 |
# Video frame input
|
100 |
-
frame = predict_video_frame(frame)
|
101 |
return frame
|
102 |
|
103 |
def predict_image(frame):
|
@@ -128,32 +128,10 @@ def predict_image(frame):
|
|
128 |
def predict_video_frame(frame):
|
129 |
return predict_image(frame)
|
130 |
|
131 |
-
# demo = gr.Interface(
|
132 |
-
# fn=predict_emotion,
|
133 |
-
# inputs=gr.inputs.Video(type="numpy"), # Accepts video file input
|
134 |
-
# outputs=gr.outputs.Video("output.mp4"), # Outputs processed video
|
135 |
-
# examples=[
|
136 |
-
# os.path.join(os.path.dirname(__file__), "images/chandler.jpeg"),
|
137 |
-
# os.path.join(os.path.dirname(__file__), "images/janice.jpeg"),
|
138 |
-
# os.path.join(os.path.dirname(__file__), "images/joey.jpeg"),
|
139 |
-
# os.path.join(os.path.dirname(__file__), "images/phoebe.jpeg"),
|
140 |
-
# os.path.join(os.path.dirname(__file__), "images/rachel_monica.jpeg"),
|
141 |
-
# os.path.join(os.path.dirname(__file__), "images/ross.jpeg"),
|
142 |
-
# os.path.join(os.path.dirname(__file__), "images/gunther.jpeg"),
|
143 |
-
# os.path.join(os.path.dirname(__file__), "images/joey_shocked.mp4")
|
144 |
-
# ],
|
145 |
-
# title="How are you feeling?",
|
146 |
-
# theme="shivi/calm_seafoam"
|
147 |
-
# )
|
148 |
-
|
149 |
demo = gr.Interface(
|
150 |
fn = predict_emotion,
|
151 |
-
inputs = [gr.
|
152 |
-
outputs = gr.
|
153 |
-
# gr.components.Image(label="Predicted Emotion"),
|
154 |
-
# gr.components.Label(num_top_classes=2, label="Top 2 Probabilities")
|
155 |
-
#flagging_options=["blurry", "incorrect", "other"],
|
156 |
-
|
157 |
examples = [
|
158 |
[os.path.join(os.path.dirname(__file__), "images/chandler.jpeg")],
|
159 |
[os.path.join(os.path.dirname(__file__), "images/janice.jpeg")],
|
@@ -162,12 +140,11 @@ demo = gr.Interface(
|
|
162 |
[os.path.join(os.path.dirname(__file__), "images/rachel_monica.jpeg")],
|
163 |
[os.path.join(os.path.dirname(__file__), "images/ross.jpeg")],
|
164 |
[os.path.join(os.path.dirname(__file__), "images/gunther.jpeg")],
|
165 |
-
[os.path.join(os.path.dirname(__file__), "images/joey_shocked.mp4")]
|
166 |
],
|
167 |
title = "How are you feeling?",
|
168 |
theme = "shivi/calm_seafoam"
|
169 |
)
|
170 |
|
171 |
-
|
172 |
if __name__ == "__main__":
|
173 |
demo.launch()
|
|
|
97 |
frame = predict_image(frame)
|
98 |
else:
|
99 |
# Video frame input
|
100 |
+
frame = predict_video_frame(frame.read()) # Convert NamedString to bytes
|
101 |
return frame
|
102 |
|
103 |
def predict_image(frame):
|
|
|
128 |
def predict_video_frame(frame):
|
129 |
return predict_image(frame)
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
demo = gr.Interface(
|
132 |
fn = predict_emotion,
|
133 |
+
inputs = [gr.inputs.Image(type="numpy"), gr.inputs.Video()], # Corrected input components
|
134 |
+
outputs = gr.outputs.Image(),
|
|
|
|
|
|
|
|
|
135 |
examples = [
|
136 |
[os.path.join(os.path.dirname(__file__), "images/chandler.jpeg")],
|
137 |
[os.path.join(os.path.dirname(__file__), "images/janice.jpeg")],
|
|
|
140 |
[os.path.join(os.path.dirname(__file__), "images/rachel_monica.jpeg")],
|
141 |
[os.path.join(os.path.dirname(__file__), "images/ross.jpeg")],
|
142 |
[os.path.join(os.path.dirname(__file__), "images/gunther.jpeg")],
|
143 |
+
[open(os.path.join(os.path.dirname(__file__), "images/joey_shocked.mp4"), "rb")] # Open file in binary mode
|
144 |
],
|
145 |
title = "How are you feeling?",
|
146 |
theme = "shivi/calm_seafoam"
|
147 |
)
|
148 |
|
|
|
149 |
if __name__ == "__main__":
|
150 |
demo.launch()
|