D0k-tor commited on
Commit
7a63258
·
1 Parent(s): 0b0d969

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -17
app.py CHANGED
@@ -28,25 +28,11 @@ def predict(image, max_length=64, num_beams=4):
28
 
29
  input = gr.inputs.Image(label="Upload any Image", type = 'pil', optional=True)
30
  output = gr.outputs.Textbox(type="text",label="Captions")
31
- examples = ["example1.jpg"]
32
- print("------------------------- 6 -------------------------\n")
33
- title = "Image to Text ViT with LORA"
34
-
35
- # interface = gr.Interface(
36
-
37
- # fn=predict,
38
- # description=description,
39
- # inputs = input,
40
- # theme="grass",
41
- # outputs=output,
42
- # examples=examples,
43
- # title=title,
44
- # )
45
- # interface.launch(debug=True)
46
 
47
  with gr.Blocks() as demo:
48
 
49
-
50
  gr.HTML(
51
  """
52
  <div style="text-align: center; max-width: 1200px; margin: 20px auto;">
@@ -63,6 +49,7 @@ with gr.Blocks() as demo:
63
 
64
  </div>
65
  """)
 
66
  with gr.Row():
67
  with gr.Column(scale=1):
68
  img = gr.inputs.Image(label="Upload any Image", type = 'pil', optional=True)
@@ -71,8 +58,10 @@ with gr.Blocks() as demo:
71
  out = gr.outputs.Textbox(type="text",label="Captions")
72
 
73
  button.click(predict, inputs=[img], outputs=[out])
 
 
74
  gr.Examples(
75
- examples=[os.path.join(os.path.dirname(__file__), "example1.jpg")],
76
  inputs=img,
77
  outputs=out,
78
  fn=predict,
 
28
 
29
  input = gr.inputs.Image(label="Upload any Image", type = 'pil', optional=True)
30
  output = gr.outputs.Textbox(type="text",label="Captions")
31
+ examples_folder = os.path.join(os.path.dirname(__file__), "examples")
32
+ examples = [os.path.join(examples_folder, file) for file in os.listdir(examples_folder)]
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  with gr.Blocks() as demo:
35
 
 
36
  gr.HTML(
37
  """
38
  <div style="text-align: center; max-width: 1200px; margin: 20px auto;">
 
49
 
50
  </div>
51
  """)
52
+
53
  with gr.Row():
54
  with gr.Column(scale=1):
55
  img = gr.inputs.Image(label="Upload any Image", type = 'pil', optional=True)
 
58
  out = gr.outputs.Textbox(type="text",label="Captions")
59
 
60
  button.click(predict, inputs=[img], outputs=[out])
61
+
62
+
63
  gr.Examples(
64
+ examples=examples,
65
  inputs=img,
66
  outputs=out,
67
  fn=predict,