Add application file
Browse files
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(
|
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 |
-
|
82 |
-
|
|
|
83 |
with gr.Row():
|
84 |
-
submit_button = gr.Button("
|
85 |
-
|
|
|
86 |
|
87 |
-
submit_button.click(fn=analyze_image_direct, inputs=[
|
|
|
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()
|