Create draggan_huggingface.py
Browse files- draggan_huggingface.py +13 -0
draggan_huggingface.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from draggan_huggingface import DragGANHuggingFace
|
| 2 |
+
# راهاندازی مدل
|
| 3 |
+
draggan = DragGANHuggingFace()
|
| 4 |
+
# بارگذاری تصویر
|
| 5 |
+
image = draggan.load_image('path/to/image.jpg')
|
| 6 |
+
# تعریف نقاط کنترل (نقاطی که میخواهیم حرکت دهیم)
|
| 7 |
+
control_points = [(x1, y1), (x2, y2)]
|
| 8 |
+
# تعریف نقاط هدف (جایی که میخواهیم نقاط کنترل حرکت کنند)
|
| 9 |
+
target_points = [(x1, y1), (x2, y2)]
|
| 10 |
+
# اجرای DragGAN
|
| 11 |
+
result = draggan.drag_image(image, control_points, target_points, iterations=20)
|
| 12 |
+
# ذخیره نتیجه
|
| 13 |
+
result.save('output.jpg')
|