Spaces:
Runtime error
Runtime error
Commit
·
e8fcedb
1
Parent(s):
5d7365b
Refactor app.py to initialize FLUX pipeline and VAE on CUDA, enhancing image generation capabilities
Browse files
app.py
CHANGED
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
from gradio_litmodel3d import LitModel3D
|
@@ -15,15 +22,9 @@ from trellis.pipelines import TrellisImageTo3DPipeline
|
|
15 |
from trellis.representations import Gaussian, MeshExtractResult
|
16 |
from trellis.utils import render_utils, postprocessing_utils
|
17 |
from gradio_client import Client
|
18 |
-
from diffusers import FluxPipeline, AutoencoderKL
|
19 |
-
from live_preview_helpers import flux_pipe_call_that_returns_an_iterable_of_images
|
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 |
-
good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=torch.bfloat16)
|
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):
|
28 |
llm_prompt_template = """You are tasked with creating a concise yet highly detailed description of an item to be used for generating an image in a game development pipeline. The image should show the **entire item** with no parts cropped or hidden. The background should always be plain and monocolor, with no focus on it.
|
29 |
|
@@ -56,7 +57,6 @@ Focus on the item itself, ensuring it is fully described, and specify a plain, w
|
|
56 |
@spaces.GPU(duration=75)
|
57 |
def generate_item_image(object_t2i_prompt):
|
58 |
trial_id = ""
|
59 |
-
pipe.cuda()
|
60 |
for image in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
61 |
prompt=object_t2i_prompt,
|
62 |
guidance_scale=3.5,
|
|
|
1 |
+
from diffusers import FluxPipeline, AutoencoderKL
|
2 |
+
from live_preview_helpers import flux_pipe_call_that_returns_an_iterable_of_images
|
3 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
4 |
+
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to(device)
|
5 |
+
good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=torch.bfloat16).to(device)
|
6 |
+
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
7 |
+
|
8 |
import gradio as gr
|
9 |
import spaces
|
10 |
from gradio_litmodel3d import LitModel3D
|
|
|
22 |
from trellis.representations import Gaussian, MeshExtractResult
|
23 |
from trellis.utils import render_utils, postprocessing_utils
|
24 |
from gradio_client import Client
|
|
|
|
|
25 |
|
26 |
llm_client = Client("Qwen/Qwen2.5-72B-Instruct")
|
27 |
|
|
|
|
|
|
|
|
|
28 |
def generate_t2i_prompt(item_name):
|
29 |
llm_prompt_template = """You are tasked with creating a concise yet highly detailed description of an item to be used for generating an image in a game development pipeline. The image should show the **entire item** with no parts cropped or hidden. The background should always be plain and monocolor, with no focus on it.
|
30 |
|
|
|
57 |
@spaces.GPU(duration=75)
|
58 |
def generate_item_image(object_t2i_prompt):
|
59 |
trial_id = ""
|
|
|
60 |
for image in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
61 |
prompt=object_t2i_prompt,
|
62 |
guidance_scale=3.5,
|