Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,20 +30,23 @@ pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
|
| 30 |
)
|
| 31 |
|
| 32 |
# 4. LCM-LoRA लोड करें (तेज़ स्पीड के लिए)
|
|
|
|
| 33 |
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
|
| 34 |
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
|
| 35 |
|
| 36 |
-
# 5. CPU पर रखें
|
| 37 |
pipe.to("cpu")
|
| 38 |
|
| 39 |
def edit_image(original_image_path, prompt):
|
|
|
|
|
|
|
| 40 |
# इमेज को लोड और प्रोसेस करें
|
| 41 |
image = Image.open(original_image_path).convert("RGB")
|
| 42 |
|
| 43 |
-
# Canny एज डिटेक्शन
|
| 44 |
control_image = canny_detector(image)
|
| 45 |
|
| 46 |
-
# इमेज जनरेशन (LCM के कारण केवल
|
| 47 |
image_edited = pipe(
|
| 48 |
prompt=prompt,
|
| 49 |
image=control_image,
|
|
@@ -53,7 +56,7 @@ def edit_image(original_image_path, prompt):
|
|
| 53 |
).images[0]
|
| 54 |
|
| 55 |
image_edited.save("edited_output.png")
|
| 56 |
-
print("इमेज एडिट होकर सेव हो गई है: edited_output.png")
|
| 57 |
|
| 58 |
-
#
|
| 59 |
# edit_image("image_0.png", "A beautiful landscape with cherry blossom trees, realistic, high quality")
|
|
|
|
| 30 |
)
|
| 31 |
|
| 32 |
# 4. LCM-LoRA लोड करें (तेज़ स्पीड के लिए)
|
| 33 |
+
# peft इंस्टॉल होने के बाद यह लाइन बिना एरर के काम करेगी
|
| 34 |
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
|
| 35 |
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
|
| 36 |
|
| 37 |
+
# 5. CPU पर रखें (चूँकि आप इसे फ्री CPU स्पेस पर चला रहे हैं)
|
| 38 |
pipe.to("cpu")
|
| 39 |
|
| 40 |
def edit_image(original_image_path, prompt):
|
| 41 |
+
print("इमेज प्रोसेस हो रही है, कृपया प्रतीक्षा करें...")
|
| 42 |
+
|
| 43 |
# इमेज को लोड और प्रोसेस करें
|
| 44 |
image = Image.open(original_image_path).convert("RGB")
|
| 45 |
|
| 46 |
+
# Canny एज डिटेक्शन (इमेज का ढांचा निकालने के लिए)
|
| 47 |
control_image = canny_detector(image)
|
| 48 |
|
| 49 |
+
# इमेज जनरेशन (LCM के कारण केवल 5 स्टेप्स काफी हैं)
|
| 50 |
image_edited = pipe(
|
| 51 |
prompt=prompt,
|
| 52 |
image=control_image,
|
|
|
|
| 56 |
).images[0]
|
| 57 |
|
| 58 |
image_edited.save("edited_output.png")
|
| 59 |
+
print("सफलता! इमेज एडिट होकर सेव हो गई है: edited_output.png")
|
| 60 |
|
| 61 |
+
# टेस्टिंग के लिए यहाँ अपनी इमेज का नाम और प्रॉम्ट डालें:
|
| 62 |
# edit_image("image_0.png", "A beautiful landscape with cherry blossom trees, realistic, high quality")
|