Spaces:
Sleeping
Sleeping
Raniahossam33
commited on
Commit
•
d2602c5
1
Parent(s):
82b369d
Upload app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,35 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
from fish_feeding import FishFeeding
|
4 |
-
|
5 |
model = FishFeeding()
|
6 |
model.load_models()
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
total_feed, times = model.final_fish_feed(images)
|
13 |
return {"total_feed": total_feed, "times": times}
|
14 |
|
15 |
-
inputs = gr.
|
16 |
outputs = gr.JSON(label="Fish Feeding Results")
|
17 |
|
18 |
app = gr.Interface(fish_feeding, inputs=inputs, outputs=outputs, title="Fish Feeding Predictor")
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
from fish_feeding import FishFeeding
|
4 |
+
import cv2
|
5 |
model = FishFeeding()
|
6 |
model.load_models()
|
7 |
|
8 |
+
|
9 |
+
def FrameCapture(path):
|
10 |
+
|
11 |
+
# Path to video file
|
12 |
+
vidObj = cv2.VideoCapture(path)
|
13 |
+
success = 1
|
14 |
+
images = []
|
15 |
+
count = 0
|
16 |
+
while success:
|
17 |
+
|
18 |
+
success, image = vidObj.read()
|
19 |
+
|
20 |
+
if success and count % 3 == 0:
|
21 |
|
22 |
+
image= np.array(image, dtype=np.uint8)
|
23 |
+
images.append(image)
|
24 |
+
count += 1
|
25 |
+
return images
|
26 |
+
|
27 |
+
def fish_feeding(images):
|
28 |
+
images = FrameCapture(images)
|
29 |
total_feed, times = model.final_fish_feed(images)
|
30 |
return {"total_feed": total_feed, "times": times}
|
31 |
|
32 |
+
inputs = gr.Video(label="Upload fish images")
|
33 |
outputs = gr.JSON(label="Fish Feeding Results")
|
34 |
|
35 |
app = gr.Interface(fish_feeding, inputs=inputs, outputs=outputs, title="Fish Feeding Predictor")
|