Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -13,18 +13,27 @@ def ghibli_transform(input_image, prompt="ghibli style", strength=0.75, guidance
|
|
13 |
print(f"Input received: {input_image is not None}")
|
14 |
print(f"Input type: {type(input_image)}")
|
15 |
if input_image is None:
|
16 |
-
raise gr.Error("Please upload an image before clicking Transform
|
17 |
|
|
|
18 |
try:
|
|
|
19 |
init_image = input_image.resize((768, 768)).convert("RGB")
|
20 |
-
print(f"Converted
|
|
|
|
|
21 |
except Exception as e:
|
22 |
raise gr.Error(f"Failed to process image: {str(e)}")
|
23 |
|
|
|
|
|
|
|
|
|
|
|
24 |
try:
|
25 |
output = pipe(
|
26 |
prompt=prompt,
|
27 |
-
init_image=
|
28 |
strength=strength,
|
29 |
guidance_scale=guidance_scale,
|
30 |
num_inference_steps=50
|
@@ -42,7 +51,7 @@ with gr.Blocks(title="Ghibli Diffusion Image Transformer") as demo:
|
|
42 |
|
43 |
with gr.Row():
|
44 |
with gr.Column():
|
45 |
-
input_img = gr.Image(label="Upload Image", type="pil")
|
46 |
prompt = gr.Textbox(label="Prompt", value="ghibli style")
|
47 |
strength = gr.Slider(0, 1, value=0.75, step=0.05, label="Strength (How much to transform)")
|
48 |
guidance = gr.Slider(1, 20, value=7.5, step=0.5, label="Guidance Scale")
|
|
|
13 |
print(f"Input received: {input_image is not None}")
|
14 |
print(f"Input type: {type(input_image)}")
|
15 |
if input_image is None:
|
16 |
+
raise gr.Error("No image uploaded! Please upload an image before clicking Transform.")
|
17 |
|
18 |
+
# Process the input image
|
19 |
try:
|
20 |
+
print(f"Input size: {input_image.size}, mode: {input_image.mode}")
|
21 |
init_image = input_image.resize((768, 768)).convert("RGB")
|
22 |
+
print(f"Converted init_image size: {init_image.size}, mode: {init_image.mode}")
|
23 |
+
except AttributeError as e:
|
24 |
+
raise gr.Error(f"Input is not a valid image: {str(e)}")
|
25 |
except Exception as e:
|
26 |
raise gr.Error(f"Failed to process image: {str(e)}")
|
27 |
|
28 |
+
# Convert to NumPy array as a workaround
|
29 |
+
init_image_np = np.array(init_image)
|
30 |
+
print(f"Converted to NumPy: {type(init_image_np)}, shape: {init_image_np.shape}")
|
31 |
+
|
32 |
+
# Generate the Ghibli-style image
|
33 |
try:
|
34 |
output = pipe(
|
35 |
prompt=prompt,
|
36 |
+
init_image=init_image_np, # Pass NumPy array instead
|
37 |
strength=strength,
|
38 |
guidance_scale=guidance_scale,
|
39 |
num_inference_steps=50
|
|
|
51 |
|
52 |
with gr.Row():
|
53 |
with gr.Column():
|
54 |
+
input_img = gr.Image(label="Upload Image", type="pil")
|
55 |
prompt = gr.Textbox(label="Prompt", value="ghibli style")
|
56 |
strength = gr.Slider(0, 1, value=0.75, step=0.05, label="Strength (How much to transform)")
|
57 |
guidance = gr.Slider(1, 20, value=7.5, step=0.5, label="Guidance Scale")
|