File size: 980 Bytes
d02e83e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d78a11f
d02e83e
 
 
 
 
d78a11f
 
d02e83e
 
5a7c59c
d02e83e
5a7c59c
d02e83e
 
 
 
 
 
 
5a7c59c
d02e83e
d78a11f
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
import gradio as gr
import shutil

import urllib.request
import sys
import os
import urllib.request
import zipfile

sys.path.append(".")


gr.close_all()


urllib.request.urlretrieve("https://storage.googleapis.com/models-gradio/products/products.zip", "products.zip")


with zipfile.ZipFile("products.zip", 'r') as zip_ref:
    zip_ref.extractall()

from model import prediction

def predict(img):
    
    prediction_img, text, t_process  = prediction(img)
    
    return  t_process, str(text), prediction_img,


sample_images = ["dataset/" + name for name in os.listdir("dataset")]
    

gr.Interface(fn=predict,
             inputs=[gr.Image(label="image à tester" ,type="filepath")],
             outputs=[gr.Textbox(label="temps"), gr.Textbox(label="analyse"), gr.Image(label ="résultat") ],
             css="footer {visibility: hidden} body}, .gradio-container {background-color: white}",
             examples=sample_images).launch(server_name="0.0.0.0", share=False)