Spaces:
Sleeping
Sleeping
tokeron
commited on
Commit
•
773453a
1
Parent(s):
d55e7d8
app updated
Browse files
app.py
CHANGED
@@ -3,64 +3,16 @@ import sys
|
|
3 |
# sys.path.append("LaVi-Bridge/test")
|
4 |
# from llama2_unet_diffusion_lens import call_diffusion_lens
|
5 |
from diffusion_lens import get_images
|
6 |
-
|
7 |
import os
|
8 |
import subprocess
|
9 |
|
10 |
-
def prepare_images(images):
|
11 |
-
return images
|
12 |
-
|
13 |
-
|
14 |
-
# def call_diffusion_lens(prompt):
|
15 |
-
# # os.chdir('LaVi-Bridge/test')
|
16 |
-
# command = f"python -u llama2_unet.py --ckpt_dir 'LaVi-Bridge/llama2_unet' --output_dir 'output' --llama2_dir 'meta-llama/Llama-2-7b-hf' --prompt '{prompt}'"
|
17 |
-
# subprocess.run(command, shell=True)
|
18 |
-
# return 'output'
|
19 |
-
|
20 |
-
|
21 |
def get_prompt(prompt):
|
22 |
print('prompt:', prompt)
|
23 |
print('calling diffusion lens')
|
24 |
-
|
25 |
-
# parser.add_argument("--ckpt_dir", type=str, default="")
|
26 |
-
# parser.add_argument("--output_dir", type=str, default="")
|
27 |
-
# parser.add_argument("--llama2_dir", type=str, default="")
|
28 |
-
# parser.add_argument("--prompts_path", type=str, default="inputs/in.txt")
|
29 |
-
# parser.add_argument("--use_chat", action="store_true")
|
30 |
-
# parser.add_argument("--generate_text", action="store_true")
|
31 |
-
# parser.add_argument("--dont_use_lora", action="store_true")
|
32 |
-
# parser.add_argument("--is_gradio", action="store_true")
|
33 |
-
|
34 |
-
# args = {
|
35 |
-
# 'ckpt_dir': 'LaVi-Bridge/LaVi-Bridge/llama2_unet',
|
36 |
-
# 'output_dir': 'output',
|
37 |
-
# 'llama2_dir': 'meta-llama/Llama-2-7b-hf',
|
38 |
-
# 'prompt': prompt,
|
39 |
-
# 'use_chat': False,
|
40 |
-
# 'generate_text': False,
|
41 |
-
# 'dont_use_lora': False,
|
42 |
-
# 'is_gradio': True,
|
43 |
-
# 'prompts_path': None
|
44 |
-
# }
|
45 |
-
# images = call_diffusion_lens(args, prompt)
|
46 |
-
# print('done calling diffusion lens')
|
47 |
-
# print('number of images:', len(images))
|
48 |
-
# images = prepare_images(images)
|
49 |
-
# print('done preparing images')
|
50 |
image = get_images(prompt, skip_layers=0)
|
51 |
return image
|
52 |
|
53 |
-
if __name__ == '__main__':
|
54 |
-
print('starting')
|
55 |
-
get_prompt("A photo of a cat")
|
56 |
-
print('done')
|
57 |
-
|
58 |
-
|
59 |
-
# iface = gr.Interface(fn=get_prompt, inputs="text", outputs="image", title="Diffusion Lens")
|
60 |
-
# iface.launch()
|
61 |
-
|
62 |
-
import gradio as gr
|
63 |
-
|
64 |
def display_images(images):
|
65 |
# Prepare images for display
|
66 |
return [gr.Image(image) for image in images]
|
|
|
3 |
# sys.path.append("LaVi-Bridge/test")
|
4 |
# from llama2_unet_diffusion_lens import call_diffusion_lens
|
5 |
from diffusion_lens import get_images
|
6 |
+
import gradio as gr
|
7 |
import os
|
8 |
import subprocess
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def get_prompt(prompt):
|
11 |
print('prompt:', prompt)
|
12 |
print('calling diffusion lens')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
image = get_images(prompt, skip_layers=0)
|
14 |
return image
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def display_images(images):
|
17 |
# Prepare images for display
|
18 |
return [gr.Image(image) for image in images]
|