File size: 937 Bytes
82b369d
 
 
d2602c5
82b369d
 
 
d2602c5
 
 
 
 
 
 
 
 
 
 
 
 
82b369d
d2602c5
 
 
 
 
 
 
82b369d
 
 
d2602c5
82b369d
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()