RoyalEagle commited on
Commit
39c6d42
1 Parent(s): 8329bcc

Create app.py

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