File size: 1,265 Bytes
85db903
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
from charset_normalizer import detect
import numpy as np
import gradio as gr
import torch
import torch.nn as nn
import cv2
import os
from numpy import random
from metadata.utils.utils import decodeImage
from metadata.predictor_yolo_detector.detector_test import Detector
from PIL import Image

class ClientApp:
    def __init__(self):
        self.filename = "inputImage.jpg"
        #modelPath = 'research/ssd_mobilenet_v1_coco_2017_11_17'
        self.objectDetection = Detector(self.filename)




clApp = ClientApp()

def predict_image(input_img):

    img = Image.fromarray(input_img)
    img.save("./metadata/predictor_yolo_detector/inference/images/"+ clApp.filename)
    resultant_img = clApp.objectDetection.detect_action()
                                                            
        
    return resultant_img

demo = gr.Blocks()

with demo:
    gr.Markdown(
    """
    <h1 align = "center"> Warehouse Apparel Detection </h1>
    """)
    
    detect = gr.Interface(predict_image, 'image', 'image', examples=[
        os.path.join(os.path.dirname(__file__), "images/image_1.jpg"),
        os.path.join(os.path.dirname(__file__), "images/image_2.jpg"),
        os.path.join(os.path.dirname(__file__), "images/image_3.jpg")
        ])

demo.launch()