Ahmed007 commited on
Commit
0ec0dbf
·
1 Parent(s): 3127731

Add application file

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -4,7 +4,6 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
4
  from PIL import Image
5
  import gradio as gr
6
  from typing import Iterable
7
- import gradio as gr
8
  from gradio.themes.base import Base
9
  from gradio.themes.utils import colors, fonts, sizes
10
  import time
@@ -17,10 +16,10 @@ model = AutoModelForCausalLM.from_pretrained(
17
  )
18
  tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision)
19
 
20
- def analyze_image_direct(image, question):
21
  # This is a placeholder function. You need to implement the logic based on your model's capabilities.
22
  # For demonstration, it returns a static response.
23
- return "This is a placeholder answer."
24
 
25
  class Seafoam(Base):
26
  def __init__(
@@ -78,12 +77,15 @@ seafoam = Seafoam()
78
 
79
  with gr.Blocks(theme=seafoam) as demo:
80
  with gr.Row():
81
- image_input = gr.Image(type="pil")
82
- question_input = gr.Textbox(lines=2, placeholder="Enter your question here...")
 
83
  with gr.Row():
84
- submit_button = gr.Button("Analyze")
85
- output = gr.Textbox()
 
86
 
87
- submit_button.click(fn=analyze_image_direct, inputs=[image_input, question_input], outputs=output)
 
88
 
89
- demo.launch()
 
4
  from PIL import Image
5
  import gradio as gr
6
  from typing import Iterable
 
7
  from gradio.themes.base import Base
8
  from gradio.themes.utils import colors, fonts, sizes
9
  import time
 
16
  )
17
  tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision)
18
 
19
+ def analyze_image_direct(name, count):
20
  # This is a placeholder function. You need to implement the logic based on your model's capabilities.
21
  # For demonstration, it returns a static response.
22
+ return f"This is a placeholder answer for {name} with count {count}."
23
 
24
  class Seafoam(Base):
25
  def __init__(
 
77
 
78
  with gr.Blocks(theme=seafoam) as demo:
79
  with gr.Row():
80
+ name_input = gr.Textbox(label="Name", placeholder="Enter your name here...")
81
+ with gr.Row():
82
+ count_slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1, value=0)
83
  with gr.Row():
84
+ submit_button = gr.Button("Submit")
85
+ clear_button = gr.Button("Clear")
86
+ output = gr.Textbox(label="Output")
87
 
88
+ submit_button.click(fn=analyze_image_direct, inputs=[name_input, count_slider], outputs=output)
89
+ clear_button.click(fn=lambda: ("", 0, ""), inputs=None, outputs=[name_input, count_slider, output])
90
 
91
+ demo.launch()