jruneofficial commited on
Commit
08b5d9c
1 Parent(s): d669328

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #@title Text2Art Gradio UI
2
+ import gradio as gr
3
+ import torch
4
+ import clipit
5
+
6
+ # Define the main function
7
+ def generate(prompt, quality, style, aspect):
8
+ torch.cuda.empty_cache()
9
+ clipit.reset_settings()
10
+
11
+ use_pixeldraw = (style == 'pixel art')
12
+ use_clipdraw = (style == 'painting')
13
+ clipit.add_settings(prompts=prompt,
14
+ aspect=aspect,
15
+ quality=quality,
16
+ use_pixeldraw=use_pixeldraw,
17
+ use_clipdraw=use_clipdraw,
18
+ make_video=True)
19
+
20
+ settings = clipit.apply_settings()
21
+ clipit.do_init(settings)
22
+ clipit.do_run(settings)
23
+
24
+ return 'output.png', 'output.mp4'
25
+
26
+ # Create the UI
27
+ prompt = gr.inputs.Textbox(default="Underwater city", label="Text Prompt")
28
+ quality = gr.inputs.Radio(choices=['draft', 'normal', 'better'], label="Quality")
29
+ style = gr.inputs.Radio(choices=['image', 'painting','pixel art'], label="Type")
30
+ aspect = gr.inputs.Radio(choices=['square', 'widescreen','portrait'], label="Size")
31
+
32
+ # Launch the demo
33
+ iface = gr.Interface(generate, inputs=[prompt, quality, style, aspect], outputs=['image', 'video'], enable_queue=True, live=False)
34
+ iface.launch(debug=True)