RoyalEagle commited on
Commit
7458417
1 Parent(s): e09c4ce

Create new file

Browse files
Files changed (1) hide show
  1. app.ipynb +55 -0
app.ipynb ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %%capture
2
+ !pip install torch==1.9.0+cu111 torchtext==0.10.0 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch/ -f https://download.pytorch.org/whl/torchvision/
3
+
4
+ !git clone https://github.com/openai/CLIP
5
+ # !pip install taming-transformers
6
+ !git clone https://github.com/CompVis/taming-transformers.git
7
+ !rm -Rf pixray
8
+ !git clone https://github.com/dribnet/pixray
9
+ !pip install ftfy regex tqdm omegaconf pytorch-lightning
10
+ !pip install kornia==0.6.1
11
+ !pip install imageio-ffmpeg
12
+ !pip install einops
13
+ !pip install torch-optimizer
14
+ !pip install easydict
15
+ !pip install braceexpand
16
+ !pip install git+https://github.com/pvigier/perlin-numpy
17
+ !mkdir steps
18
+ !mkdir models
19
+ !wget https://user-images.githubusercontent.com/945979/126260797-adc60317-9518-40de-8700-b1f93e81e0ec.png -O this_is_fine.png
20
+ !wget https://user-images.githubusercontent.com/945979/126415385-d70ff2b0-f021-4238-9621-6180d33b242c.jpg -O perfume.jpg
21
+ !pip install gradio==2.5.1
22
+ import sys
23
+ sys.path.append("pixray")
24
+
25
+ import gradio as gr
26
+ import torch
27
+ import pixray
28
+
29
+ # Define the main function
30
+ def generate(prompt, quality, style, aspect):
31
+ torch.cuda.empty_cache()
32
+ pixray.reset_settings()
33
+
34
+ # use_pixeldraw = (style == 'pixel art')
35
+ # use_clipdraw = (style == 'painting')
36
+ pixray.add_settings(prompts=prompt,
37
+ aspect=aspect,
38
+ quality=quality,
39
+ make_video=True)
40
+
41
+ settings = pixray.apply_settings()
42
+ pixray.do_init(settings)
43
+ pixray.do_run(settings)
44
+
45
+ return 'output.png', 'output.mp4'
46
+
47
+ # Create the UI
48
+ prompt = gr.inputs.Textbox(default="Underwater city", label="Text Prompt")
49
+ quality = gr.inputs.Radio(choices=['draft', 'normal', 'better'], label="Quality")
50
+ # style = gr.inputs.Radio(choices=['image', 'painting','pixel art'], label="Type")
51
+ aspect = gr.inputs.Radio(choices=['square', 'widescreen','portrait'], label="Size")
52
+
53
+ # Launch the demo
54
+ iface = gr.Interface(generate, inputs=[prompt, quality, aspect], outputs=['image', 'video'], enable_queue=True, live=False)
55
+ iface.launch(debug=True)