Upload Qwen_Qwen-Image-Edit_2.py with huggingface_hub
Browse files- Qwen_Qwen-Image-Edit_2.py +32 -2
Qwen_Qwen-Image-Edit_2.py
CHANGED
|
@@ -12,7 +12,22 @@
|
|
| 12 |
|
| 13 |
try:
|
| 14 |
import os
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
with open('Qwen_Qwen-Image-Edit_2.txt', 'w', encoding='utf-8') as f:
|
| 17 |
f.write('Everything was good in Qwen_Qwen-Image-Edit_2.txt')
|
| 18 |
except Exception as e:
|
|
@@ -28,7 +43,22 @@ except Exception as e:
|
|
| 28 |
import traceback
|
| 29 |
f.write('''```CODE:
|
| 30 |
import os
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
```
|
| 33 |
|
| 34 |
ERROR:
|
|
|
|
| 12 |
|
| 13 |
try:
|
| 14 |
import os
|
| 15 |
+
from huggingface_hub import InferenceClient
|
| 16 |
+
|
| 17 |
+
client = InferenceClient(
|
| 18 |
+
provider="auto",
|
| 19 |
+
api_key=os.environ["HF_TOKEN"],
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
with open("cat.png", "rb") as image_file:
|
| 23 |
+
input_image = image_file.read()
|
| 24 |
+
|
| 25 |
+
# output is a PIL.Image object
|
| 26 |
+
image = client.image_to_image(
|
| 27 |
+
input_image,
|
| 28 |
+
prompt="Turn the cat into a tiger.",
|
| 29 |
+
model="Qwen/Qwen-Image-Edit",
|
| 30 |
+
)
|
| 31 |
with open('Qwen_Qwen-Image-Edit_2.txt', 'w', encoding='utf-8') as f:
|
| 32 |
f.write('Everything was good in Qwen_Qwen-Image-Edit_2.txt')
|
| 33 |
except Exception as e:
|
|
|
|
| 43 |
import traceback
|
| 44 |
f.write('''```CODE:
|
| 45 |
import os
|
| 46 |
+
from huggingface_hub import InferenceClient
|
| 47 |
+
|
| 48 |
+
client = InferenceClient(
|
| 49 |
+
provider="auto",
|
| 50 |
+
api_key=os.environ["HF_TOKEN"],
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
with open("cat.png", "rb") as image_file:
|
| 54 |
+
input_image = image_file.read()
|
| 55 |
+
|
| 56 |
+
# output is a PIL.Image object
|
| 57 |
+
image = client.image_to_image(
|
| 58 |
+
input_image,
|
| 59 |
+
prompt="Turn the cat into a tiger.",
|
| 60 |
+
model="Qwen/Qwen-Image-Edit",
|
| 61 |
+
)
|
| 62 |
```
|
| 63 |
|
| 64 |
ERROR:
|