Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,9 +51,11 @@ model.to(device)
|
|
51 |
|
52 |
### PeRFlow-T2I
|
53 |
# pipe_t2i = StableDiffusionPipeline.from_pretrained("Lykon/dreamshaper-8", torch_dtype=torch.float16, safety_checker=None)
|
54 |
-
pipe_t2i = StableDiffusionPipeline.from_pretrained("stablediffusionapi/disney-pixar-cartoon", torch_dtype=torch.float16, safety_checker=None)
|
55 |
-
delta_weights = UNet2DConditionModel.from_pretrained("hansyan/piecewise-rectified-flow-delta-weights", torch_dtype=torch.float16, variant="v0-1",).state_dict()
|
56 |
-
pipe_t2i = merge_delta_weights_into_unet(pipe_t2i, delta_weights)
|
|
|
|
|
57 |
pipe_t2i.scheduler = PeRFlowScheduler.from_config(pipe_t2i.scheduler.config, prediction_type="epsilon", num_time_windows=4)
|
58 |
pipe_t2i.to('cuda:0', torch.float16)
|
59 |
|
@@ -70,16 +72,18 @@ def generate(text, seed):
|
|
70 |
return image
|
71 |
|
72 |
setup_seed(int(seed))
|
73 |
-
|
|
|
|
|
74 |
samples = pipe_t2i(
|
75 |
prompt = [text],
|
76 |
-
negative_prompt = [
|
77 |
height = 512,
|
78 |
width = 512,
|
79 |
-
# num_inference_steps =
|
80 |
-
# guidance_scale =
|
81 |
-
num_inference_steps =
|
82 |
-
guidance_scale = 7,
|
83 |
output_type = 'pt',
|
84 |
).images
|
85 |
samples = torch.nn.functional.interpolate(samples, size=768, mode='bilinear')
|
@@ -104,8 +108,6 @@ def render(image, mc_resolution=256, formats=["obj"]):
|
|
104 |
rv.append(mesh_path.name)
|
105 |
return rv[0]
|
106 |
|
107 |
-
# # warm up
|
108 |
-
# _ = generate("a bird", 42)
|
109 |
|
110 |
# layout
|
111 |
css = """
|
@@ -129,7 +131,7 @@ with gr.Blocks(title="TripoSR", css=css) as interface:
|
|
129 |
|
130 |
### [PeRFlow](https://github.com/magic-research/piecewise-rectified-flow)-T2I + [TripoSR](https://github.com/VAST-AI-Research/TripoSR)
|
131 |
|
132 |
-
Two-stage synthesis: 1) generating images by PeRFlow-T2I
|
133 |
"""
|
134 |
)
|
135 |
|
@@ -146,6 +148,21 @@ with gr.Blocks(title="TripoSR", css=css) as interface:
|
|
146 |
with gr.Row():
|
147 |
textbox = gr.Textbox(label="Input Prompt", value="a colorful bird")
|
148 |
seed = gr.Textbox(label="Random Seed", value=42)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
# activate
|
151 |
textbox.submit(
|
|
|
51 |
|
52 |
### PeRFlow-T2I
|
53 |
# pipe_t2i = StableDiffusionPipeline.from_pretrained("Lykon/dreamshaper-8", torch_dtype=torch.float16, safety_checker=None)
|
54 |
+
# pipe_t2i = StableDiffusionPipeline.from_pretrained("stablediffusionapi/disney-pixar-cartoon", torch_dtype=torch.float16, safety_checker=None)
|
55 |
+
# delta_weights = UNet2DConditionModel.from_pretrained("hansyan/piecewise-rectified-flow-delta-weights", torch_dtype=torch.float16, variant="v0-1",).state_dict()
|
56 |
+
# pipe_t2i = merge_delta_weights_into_unet(pipe_t2i, delta_weights)
|
57 |
+
|
58 |
+
pipe_t2i = StableDiffusionPipeline.from_pretrained("hansyan/perflow-sd15-disney", torch_dtype=torch.float16, safety_checker=None)
|
59 |
pipe_t2i.scheduler = PeRFlowScheduler.from_config(pipe_t2i.scheduler.config, prediction_type="epsilon", num_time_windows=4)
|
60 |
pipe_t2i.to('cuda:0', torch.float16)
|
61 |
|
|
|
72 |
return image
|
73 |
|
74 |
setup_seed(int(seed))
|
75 |
+
prompt_prefix = "high quality, best quality, masterpiece; "
|
76 |
+
neg_prompt = "EasyNegative, drawn by bad-artist, sketch by bad-artist-anime, (bad_prompt:0.8), (artist name, signature, watermark:1.4), (ugly:1.2), (worst quality, poor details:1.4), bad-hands-5, badhandv4, blurry"
|
77 |
+
text = prompt_prefix + text
|
78 |
samples = pipe_t2i(
|
79 |
prompt = [text],
|
80 |
+
negative_prompt = [neg_prompt],
|
81 |
height = 512,
|
82 |
width = 512,
|
83 |
+
# num_inference_steps = 6,
|
84 |
+
# guidance_scale = 7.5,
|
85 |
+
num_inference_steps = 8,
|
86 |
+
guidance_scale = 7.5,
|
87 |
output_type = 'pt',
|
88 |
).images
|
89 |
samples = torch.nn.functional.interpolate(samples, size=768, mode='bilinear')
|
|
|
108 |
rv.append(mesh_path.name)
|
109 |
return rv[0]
|
110 |
|
|
|
|
|
111 |
|
112 |
# layout
|
113 |
css = """
|
|
|
131 |
|
132 |
### [PeRFlow](https://github.com/magic-research/piecewise-rectified-flow)-T2I + [TripoSR](https://github.com/VAST-AI-Research/TripoSR)
|
133 |
|
134 |
+
Two-stage synthesis: 1) generating images by PeRFlow-T2I; 2) rendering 3D assests.
|
135 |
"""
|
136 |
)
|
137 |
|
|
|
148 |
with gr.Row():
|
149 |
textbox = gr.Textbox(label="Input Prompt", value="a colorful bird")
|
150 |
seed = gr.Textbox(label="Random Seed", value=42)
|
151 |
+
|
152 |
+
|
153 |
+
gr.Markdown(
|
154 |
+
"""
|
155 |
+
Examples:
|
156 |
+
- a policeman
|
157 |
+
- a robot, close-up
|
158 |
+
- a red car, side view
|
159 |
+
- a blue mug
|
160 |
+
- a burger
|
161 |
+
- a tea pot
|
162 |
+
- a wooden chair
|
163 |
+
- an amazing unicorn
|
164 |
+
"""
|
165 |
+
)
|
166 |
|
167 |
# activate
|
168 |
textbox.submit(
|