Spaces:
Running
on
A100
Running
on
A100
Update
Browse files
app.py
CHANGED
@@ -305,7 +305,6 @@ class HunyuanImageApp:
|
|
305 |
def refine_image(self,
|
306 |
image: Image.Image,
|
307 |
prompt: str,
|
308 |
-
negative_prompt: str,
|
309 |
width: int,
|
310 |
height: int,
|
311 |
num_inference_steps: int,
|
@@ -315,6 +314,9 @@ class HunyuanImageApp:
|
|
315 |
try:
|
316 |
if image is None:
|
317 |
return None, "Please upload an image to refine."
|
|
|
|
|
|
|
318 |
|
319 |
torch.cuda.empty_cache()
|
320 |
|
@@ -332,7 +334,6 @@ class HunyuanImageApp:
|
|
332 |
refined_image = self.pipeline.refiner_pipeline(
|
333 |
image=image,
|
334 |
prompt=prompt,
|
335 |
-
negative_prompt=negative_prompt,
|
336 |
width=width,
|
337 |
height=height,
|
338 |
num_inference_steps=num_inference_steps,
|
@@ -555,14 +556,8 @@ def create_interface(auto_load: bool = True, use_distilled: bool = False, device
|
|
555 |
|
556 |
refine_prompt = gr.Textbox(
|
557 |
label="Refinement Prompt",
|
558 |
-
placeholder="
|
559 |
-
|
560 |
-
value="Make the image more detailed and high quality"
|
561 |
-
)
|
562 |
-
|
563 |
-
refine_negative_prompt = gr.Textbox(
|
564 |
-
label="Negative Prompt",
|
565 |
-
placeholder="",
|
566 |
lines=2,
|
567 |
value=""
|
568 |
)
|
@@ -599,6 +594,8 @@ def create_interface(auto_load: bool = True, use_distilled: bool = False, device
|
|
599 |
refined_image = gr.Image(
|
600 |
label="Refined Image",
|
601 |
type="pil",
|
|
|
|
|
602 |
height=600
|
603 |
)
|
604 |
refinement_status = gr.Textbox(
|
@@ -633,7 +630,7 @@ def create_interface(auto_load: bool = True, use_distilled: bool = False, device
|
|
633 |
refine_btn.click(
|
634 |
fn=app.refine_image,
|
635 |
inputs=[
|
636 |
-
input_image, refine_prompt,
|
637 |
refine_width, refine_height, refine_steps, refine_guidance, refine_seed
|
638 |
],
|
639 |
outputs=[refined_image, refinement_status]
|
@@ -685,7 +682,6 @@ if __name__ == "__main__":
|
|
685 |
demo = create_interface(auto_load=auto_load, use_distilled=args.use_distilled, device=args.device)
|
686 |
|
687 |
print("π Starting HunyuanImage Gradio App...")
|
688 |
-
print(f"π± The app will be available at: http://{args.host}:{args.port}")
|
689 |
print(f"π§ Auto-load pipeline: {'Yes' if auto_load else 'No'}")
|
690 |
print(f"π― Model type: {'Distilled' if args.use_distilled else 'Non-distilled'}")
|
691 |
print(f"π» Device: {args.device}")
|
|
|
305 |
def refine_image(self,
|
306 |
image: Image.Image,
|
307 |
prompt: str,
|
|
|
308 |
width: int,
|
309 |
height: int,
|
310 |
num_inference_steps: int,
|
|
|
314 |
try:
|
315 |
if image is None:
|
316 |
return None, "Please upload an image to refine."
|
317 |
+
|
318 |
+
if not prompt or prompt.strip() == "":
|
319 |
+
return None, "Please enter a refinement prompt."
|
320 |
|
321 |
torch.cuda.empty_cache()
|
322 |
|
|
|
334 |
refined_image = self.pipeline.refiner_pipeline(
|
335 |
image=image,
|
336 |
prompt=prompt,
|
|
|
337 |
width=width,
|
338 |
height=height,
|
339 |
num_inference_steps=num_inference_steps,
|
|
|
556 |
|
557 |
refine_prompt = gr.Textbox(
|
558 |
label="Refinement Prompt",
|
559 |
+
placeholder="Image description",
|
560 |
+
info="This prompt should describe the image content.",
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
lines=2,
|
562 |
value=""
|
563 |
)
|
|
|
594 |
refined_image = gr.Image(
|
595 |
label="Refined Image",
|
596 |
type="pil",
|
597 |
+
format="png",
|
598 |
+
show_download_button=True,
|
599 |
height=600
|
600 |
)
|
601 |
refinement_status = gr.Textbox(
|
|
|
630 |
refine_btn.click(
|
631 |
fn=app.refine_image,
|
632 |
inputs=[
|
633 |
+
input_image, refine_prompt,
|
634 |
refine_width, refine_height, refine_steps, refine_guidance, refine_seed
|
635 |
],
|
636 |
outputs=[refined_image, refinement_status]
|
|
|
682 |
demo = create_interface(auto_load=auto_load, use_distilled=args.use_distilled, device=args.device)
|
683 |
|
684 |
print("π Starting HunyuanImage Gradio App...")
|
|
|
685 |
print(f"π§ Auto-load pipeline: {'Yes' if auto_load else 'No'}")
|
686 |
print(f"π― Model type: {'Distilled' if args.use_distilled else 'Non-distilled'}")
|
687 |
print(f"π» Device: {args.device}")
|