yanka commited on
Commit
fee3e60
·
1 Parent(s): 89afb80

occam razor once again, ugly but functional solution

Browse files
Files changed (1) hide show
  1. app.py +1 -49
app.py CHANGED
@@ -1,53 +1,5 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
-
5
- TITLE = 'FaVQA - Fashion-related Visual Question Answering'
6
- DESCRIPTION = 'Fine-tuned ViLT with DeepFashion dataset images for VQA task'
7
- ARTICLE = 'COLOCAR DESCRIÇÃO AQUI MONA'
8
-
9
-
10
- ##########################################################
11
- # WRAPPER FUNCTION
12
- ##########################################################
13
- def predict(txt, img):
14
- pipe = pipeline(model='yanka9/vilt_finetuned_deepfashionVQA_v2')
15
- output = pipe(image=img, question=txt, top_k=2)
16
- result = {item['answer']:item['score'] for item in output}
17
-
18
- return result
19
-
20
- ##########################################################
21
- # COMPONENTS
22
- ##########################################################
23
- txt_input = gr.Textbox(
24
- max_lines=2,
25
- label='Question',
26
- show_copy_button=True
27
- )
28
-
29
- img_input = gr.Image(
30
- sources=['upload', 'clipboard'],
31
- type='pil'
32
- )
33
-
34
- label_output = gr.Label(
35
- label='Answer',
36
- num_top_classes=2
37
- )
38
-
39
- ##########################################################
40
- # BUILDER
41
- ##########################################################
42
- demo = gr.Interface(
43
- fn=predict,
44
- title=TITLE,
45
- description=DESCRIPTION,
46
- article=ARTICLE,
47
- theme='gradio/monochrome',
48
- allow_flagging='never',
49
- inputs=[txt_input, img_input],
50
- outputs=label_output
51
- )
52
 
53
  demo.launch()
 
1
  import gradio as gr
 
2
 
3
+ demo = gr.load('yanka9/vilt_finetuned_deepfashionVQA_v2', src='models')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  demo.launch()