Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -42,13 +42,15 @@ pipe = pipe.to(device)
|
|
42 |
|
43 |
# Define the inference function
|
44 |
@spaces.GPU
|
45 |
-
def ghibli_transform(input_image, prompt="GHBLI anime style photo",
|
|
|
|
|
46 |
if input_image is None:
|
47 |
raise gr.Error("No image uploaded! Please upload an image before clicking Transform.")
|
48 |
|
49 |
# Process the input image (keep it as PIL Image)
|
50 |
try:
|
51 |
-
init_image = input_image.convert("RGB").resize((
|
52 |
except Exception as e:
|
53 |
raise gr.Error(f"Failed to process image: {str(e)}")
|
54 |
|
@@ -61,10 +63,9 @@ def ghibli_transform(input_image, prompt="GHBLI anime style photo", strength=0.7
|
|
61 |
# guidance_scale=guidance_scale,
|
62 |
# num_inference_steps=num_steps # Use the UI-provided value
|
63 |
######
|
64 |
-
guidance_scale=
|
65 |
-
num_inference_steps=
|
66 |
-
|
67 |
-
height=768
|
68 |
######
|
69 |
).images[0]
|
70 |
except Exception as e:
|
@@ -81,9 +82,9 @@ with gr.Blocks(title="Ghibli Diffusion Image Transformer") as demo:
|
|
81 |
with gr.Column():
|
82 |
input_img = gr.Image(label="Upload Image", type="pil")
|
83 |
prompt = gr.Textbox(label="Prompt", value="GHBLI anime style photo")
|
84 |
-
|
85 |
-
guidance = gr.Slider(1, 20, value=
|
86 |
-
num_steps = gr.Slider(10, 100, value=
|
87 |
submit_btn = gr.Button("Transform")
|
88 |
with gr.Column():
|
89 |
output_img = gr.Image(label="Ghibli-Style Output")
|
|
|
42 |
|
43 |
# Define the inference function
|
44 |
@spaces.GPU
|
45 |
+
def ghibli_transform(input_image, prompt="GHBLI anime style photo", guidance_scale=3.5, num_steps=30):
|
46 |
+
print('canshu_guidance_scale',guidance_scale)
|
47 |
+
print('canshu_num_steps',num_steps)
|
48 |
if input_image is None:
|
49 |
raise gr.Error("No image uploaded! Please upload an image before clicking Transform.")
|
50 |
|
51 |
# Process the input image (keep it as PIL Image)
|
52 |
try:
|
53 |
+
init_image = input_image.convert("RGB").resize((1024, 768))
|
54 |
except Exception as e:
|
55 |
raise gr.Error(f"Failed to process image: {str(e)}")
|
56 |
|
|
|
63 |
# guidance_scale=guidance_scale,
|
64 |
# num_inference_steps=num_steps # Use the UI-provided value
|
65 |
######
|
66 |
+
guidance_scale=guidance_scale,
|
67 |
+
num_inference_steps=num_steps
|
68 |
+
|
|
|
69 |
######
|
70 |
).images[0]
|
71 |
except Exception as e:
|
|
|
82 |
with gr.Column():
|
83 |
input_img = gr.Image(label="Upload Image", type="pil")
|
84 |
prompt = gr.Textbox(label="Prompt", value="GHBLI anime style photo")
|
85 |
+
|
86 |
+
guidance = gr.Slider(1, 20, value=3.5, step=0.5, label="Guidance Scale")
|
87 |
+
num_steps = gr.Slider(10, 100, value=30, step=5, label="Inference Steps (Higher = Better Quality, Slower)")
|
88 |
submit_btn = gr.Button("Transform")
|
89 |
with gr.Column():
|
90 |
output_img = gr.Image(label="Ghibli-Style Output")
|