Unkowndev commited on
Commit
d3ed929
·
verified ·
1 Parent(s): 9a636d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -25
app.py CHANGED
@@ -1,32 +1,22 @@
1
  import gradio as gr
2
 
3
- # Load the model
4
- model = gr.load("models/black-forest-labs/FLUX.1-dev")
 
5
 
6
- # Define the chatbot function
7
- def chatbot(message, history):
8
- # Add the user's message to the history
9
- history.append({"role": "user", "content": message})
10
 
11
- # Get the response from the model
12
- response = model(message)
 
 
 
13
 
14
- # Add the model's response to the history
15
- history.append({"role": "assistant", "content": response})
16
 
17
- return history
18
 
19
- # Create the Gradio interface
20
- with gr.Blocks(css="footer {visibility: hidden}") as demo:
21
- gr.Markdown("# FLUX.1-dev Chatbot")
22
- gr.Markdown("Welcome! This chatbot uses the FLUX.1-dev model. Feel free to ask anything!")
23
-
24
- chatbot = gr.Chatbot(height=400)
25
- msg = gr.Textbox(label="Type your message here...")
26
- clear = gr.Button("Clear")
27
-
28
- msg.submit(chatbot, [msg, chatbot], [chatbot])
29
- clear.click(lambda: None, None, chatbot, queue=False)
30
-
31
- # Launch the interface
32
- demo.launch()
 
1
  import gradio as gr
2
 
3
+ def generate_image(prompt):
4
+ model = gr.load("models/black-forest-labs/FLUX.1-schnell")
5
+ return model(prompt)
6
 
7
+ with gr.Blocks() as demo:
8
+ gr.Markdown("# Text to Image Generator")
9
+ gr.Markdown("Enter a text prompt to generate an image using the FLUX.1-dev model.")
 
10
 
11
+ with gr.Row():
12
+ with gr.Column(scale=4):
13
+ text_input = gr.Textbox(label="Text Prompt", placeholder="Enter your prompt here...")
14
+ with gr.Column(scale=1):
15
+ submit_button = gr.Button("Generate Image")
16
 
17
+ image_output = gr.Image(label="Generated Image")
 
18
 
19
+ submit_button.click(fn=generate_image, inputs=text_input, outputs=image_output)
20
 
21
+ if __name__ == "__main__":
22
+ demo.launch()