Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
a5e543c
1
Parent(s):
5eedf0a
Replace FluxPipeline with InferenceClient for image generation and update related code
Browse files
app.py
CHANGED
@@ -16,12 +16,14 @@ 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
|
|
|
19 |
|
20 |
llm_client = Client("Qwen/Qwen2.5-72B-Instruct")
|
|
|
21 |
|
22 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
23 |
-
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to("cpu")
|
24 |
-
print(f"Flux pipeline loaded on {pipe.device}")
|
25 |
|
26 |
def generate_t2i_prompt(item_name):
|
27 |
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.
|
@@ -52,9 +54,9 @@ Focus on the item itself, ensuring it is fully described, and specify a plain, w
|
|
52 |
|
53 |
return object_t2i_prompt
|
54 |
|
55 |
-
@spaces.GPU
|
56 |
def generate_item_image(object_t2i_prompt):
|
57 |
-
image = pipe(prompt=object_t2i_prompt, guidance_scale=3.5, num_inference_steps=28, width=1024, height=1024, generator=torch.Generator("cpu").manual_seed(0), output_type="pil").images[0]
|
|
|
58 |
trial_id, processed_image = preprocess_pil_image(image)
|
59 |
return trial_id, processed_image
|
60 |
|
|
|
16 |
from trellis.utils import render_utils, postprocessing_utils
|
17 |
from gradio_client import Client
|
18 |
from diffusers import FluxPipeline
|
19 |
+
from huggingface_hub import InferenceClient
|
20 |
|
21 |
llm_client = Client("Qwen/Qwen2.5-72B-Instruct")
|
22 |
+
client = InferenceClient("black-forest-labs/FLUX.1-dev")
|
23 |
|
24 |
+
# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
25 |
+
# pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to("cpu")
|
26 |
+
# print(f"Flux pipeline loaded on {pipe.device}")
|
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.
|
|
|
54 |
|
55 |
return object_t2i_prompt
|
56 |
|
|
|
57 |
def generate_item_image(object_t2i_prompt):
|
58 |
+
# image = pipe(prompt=object_t2i_prompt, guidance_scale=3.5, num_inference_steps=28, width=1024, height=1024, generator=torch.Generator("cpu").manual_seed(0), output_type="pil").images[0]
|
59 |
+
image = client.text_to_image(object_t2i_prompt, guidance_scale=3.5, num_inference_steps=28, width=1024, height=1024)
|
60 |
trial_id, processed_image = preprocess_pil_image(image)
|
61 |
return trial_id, processed_image
|
62 |
|