Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
b1e0411
1
Parent(s):
fd7e68f
Enhance image generation by moving FluxPipeline and AutoencoderKL to GPU; update requirements to include gradio_litmodel3d
Browse files- app.py +6 -6
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
-
|
4 |
|
5 |
import os
|
6 |
os.environ['SPCONV_ALGO'] = 'native'
|
@@ -20,7 +20,8 @@ from live_preview_helpers import flux_pipe_call_that_returns_an_iterable_of_imag
|
|
20 |
|
21 |
llm_client = Client("Qwen/Qwen2.5-72B-Instruct")
|
22 |
|
23 |
-
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
|
|
24 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
25 |
|
26 |
def generate_t2i_prompt(item_name):
|
@@ -71,7 +72,6 @@ def preprocess_pil_image(image: Image.Image) -> Tuple[str, Image.Image]:
|
|
71 |
@spaces.GPU
|
72 |
def generate_item_image(object_t2i_prompt):
|
73 |
trial_id = ""
|
74 |
-
pipe.to("cuda")
|
75 |
for image in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
76 |
prompt=object_t2i_prompt,
|
77 |
guidance_scale=3.5,
|
@@ -80,6 +80,7 @@ def generate_item_image(object_t2i_prompt):
|
|
80 |
height=1024,
|
81 |
generator=torch.Generator("cpu").manual_seed(0),
|
82 |
output_type="pil",
|
|
|
83 |
):
|
84 |
yield trial_id, image
|
85 |
# img_path = t2i_client.predict(
|
@@ -93,7 +94,6 @@ def generate_item_image(object_t2i_prompt):
|
|
93 |
# api_name="/infer"
|
94 |
# )[0]
|
95 |
# image = Image.open(img_path)
|
96 |
-
pipe.to("cpu")
|
97 |
trial_id, processed_image = preprocess_pil_image(image)
|
98 |
yield trial_id, processed_image
|
99 |
|
@@ -256,8 +256,8 @@ with gr.Blocks(title="Game Items Generator") as demo:
|
|
256 |
|
257 |
with gr.Column():
|
258 |
video_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True, height=300)
|
259 |
-
|
260 |
-
model_output = gr.Model3D(label="Extracted GLB", height=300)
|
261 |
download_glb = gr.DownloadButton(label="Download GLB", interactive=False)
|
262 |
|
263 |
trial_id = gr.Textbox(visible=False)
|
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
+
from gradio_litmodel3d import LitModel3D
|
4 |
|
5 |
import os
|
6 |
os.environ['SPCONV_ALGO'] = 'native'
|
|
|
20 |
|
21 |
llm_client = Client("Qwen/Qwen2.5-72B-Instruct")
|
22 |
|
23 |
+
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to("cuda")
|
24 |
+
good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=torch.bfloat16).to("cuda")
|
25 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
26 |
|
27 |
def generate_t2i_prompt(item_name):
|
|
|
72 |
@spaces.GPU
|
73 |
def generate_item_image(object_t2i_prompt):
|
74 |
trial_id = ""
|
|
|
75 |
for image in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
76 |
prompt=object_t2i_prompt,
|
77 |
guidance_scale=3.5,
|
|
|
80 |
height=1024,
|
81 |
generator=torch.Generator("cpu").manual_seed(0),
|
82 |
output_type="pil",
|
83 |
+
good_vae=good_vae,
|
84 |
):
|
85 |
yield trial_id, image
|
86 |
# img_path = t2i_client.predict(
|
|
|
94 |
# api_name="/infer"
|
95 |
# )[0]
|
96 |
# image = Image.open(img_path)
|
|
|
97 |
trial_id, processed_image = preprocess_pil_image(image)
|
98 |
yield trial_id, processed_image
|
99 |
|
|
|
256 |
|
257 |
with gr.Column():
|
258 |
video_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True, height=300)
|
259 |
+
model_output = LitModel3D(label="Extracted GLB", exposure=20.0, height=300)
|
260 |
+
# model_output = gr.Model3D(label="Extracted GLB", height=300)
|
261 |
download_glb = gr.DownloadButton(label="Download GLB", interactive=False)
|
262 |
|
263 |
trial_id = gr.Textbox(visible=False)
|
requirements.txt
CHANGED
@@ -21,8 +21,9 @@ pymeshfix==0.17.0
|
|
21 |
igraph==0.11.8
|
22 |
git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
|
23 |
xformers==0.0.27.post2
|
24 |
-
spconv-cu120
|
25 |
transformers
|
|
|
26 |
https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.0.post2/flash_attn-2.7.0.post2+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
|
27 |
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
|
28 |
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl?download=true
|
|
|
21 |
igraph==0.11.8
|
22 |
git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
|
23 |
xformers==0.0.27.post2
|
24 |
+
spconv-cu120
|
25 |
transformers
|
26 |
+
gradio_litmodel3d
|
27 |
https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.0.post2/flash_attn-2.7.0.post2+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
|
28 |
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
|
29 |
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl?download=true
|