fish / app.py
Raniahossam33's picture
Upload app.py
d2602c5 verified
raw
history blame contribute delete
937 Bytes
import gradio as gr
import numpy as np
from fish_feeding import FishFeeding
import cv2
model = FishFeeding()
model.load_models()
def FrameCapture(path):
# Path to video file
vidObj = cv2.VideoCapture(path)
success = 1
images = []
count = 0
while success:
success, image = vidObj.read()
if success and count % 3 == 0:
image= np.array(image, dtype=np.uint8)
images.append(image)
count += 1
return images
def fish_feeding(images):
images = FrameCapture(images)
total_feed, times = model.final_fish_feed(images)
return {"total_feed": total_feed, "times": times}
inputs = gr.Video(label="Upload fish images")
outputs = gr.JSON(label="Fish Feeding Results")
app = gr.Interface(fish_feeding, inputs=inputs, outputs=outputs, title="Fish Feeding Predictor")
app.launch()