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
| 19 |
+
## Using this Space programmatically
|
| 20 |
+
|
| 21 |
+
You can call this Space from Python (via `gradio_client`) or from plain `curl`.
|
| 22 |
+
|
| 23 |
+
> ⚠️ Note: This README may lag behind the actual API definition shown in the Space’s “View API” page.
|
| 24 |
+
> If something does not work, always double-check the latest argument list and endpoint names there.
|
| 25 |
+
|
| 26 |
+
All examples assume:
|
| 27 |
+
|
| 28 |
+
- Space ID: `John6666/DiffuseCraftMod`
|
| 29 |
+
- You have a valid Hugging Face access token: `hf_xxx...` (read access is enough)
|
| 30 |
+
- You replace `hf_xxx...` with your own token
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
### 1. Python examples (`gradio_client`)
|
| 35 |
+
|
| 36 |
+
Install:
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
pip install gradio_client
|
| 40 |
+
````
|
| 41 |
+
|
| 42 |
+
#### 1.1 Synchronous API – `generate_image`
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
from gradio_client import Client
|
| 46 |
+
|
| 47 |
+
client = Client("John6666/DiffuseCraftMod", hf_token="hf_xxx...")
|
| 48 |
+
|
| 49 |
+
status, images, info = client.predict(
|
| 50 |
+
prompt="Hello!!",
|
| 51 |
+
negative_prompt=(
|
| 52 |
+
"lowres, bad anatomy, bad hands, missing fingers, extra digit, "
|
| 53 |
+
"fewer digits, worst quality, low quality"
|
| 54 |
+
),
|
| 55 |
+
num_images=1,
|
| 56 |
+
num_inference_steps=28,
|
| 57 |
+
guidance_scale=7.0,
|
| 58 |
+
clip_skip=0,
|
| 59 |
+
seed=-1,
|
| 60 |
+
height=1024,
|
| 61 |
+
width=1024,
|
| 62 |
+
model_name="votepurchase/animagine-xl-3.1",
|
| 63 |
+
vae_model="None",
|
| 64 |
+
task="txt2img",
|
| 65 |
+
api_name="/generate_image",
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
print(status)
|
| 69 |
+
print(images)
|
| 70 |
+
print(info)
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
#### 1.2 Streaming API – `generate_image_stream`
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
from gradio_client import Client
|
| 77 |
+
|
| 78 |
+
client = Client("John6666/DiffuseCraftMod", hf_token="hf_xxx...")
|
| 79 |
+
|
| 80 |
+
job = client.submit(
|
| 81 |
+
prompt="Hello!!",
|
| 82 |
+
negative_prompt=(
|
| 83 |
+
"lowres, bad anatomy, bad hands, missing fingers, extra digit, "
|
| 84 |
+
"fewer digits, worst quality, low quality"
|
| 85 |
+
),
|
| 86 |
+
num_images=1,
|
| 87 |
+
num_inference_steps=28,
|
| 88 |
+
guidance_scale=7.0,
|
| 89 |
+
clip_skip=0,
|
| 90 |
+
seed=-1,
|
| 91 |
+
height=1024,
|
| 92 |
+
width=1024,
|
| 93 |
+
model_name="votepurchase/animagine-xl-3.1",
|
| 94 |
+
vae_model="None",
|
| 95 |
+
task="txt2img",
|
| 96 |
+
api_name="/generate_image_stream",
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
for status, images, info in job:
|
| 100 |
+
# You will see progress messages, intermediate previews, and the final result.
|
| 101 |
+
print(status, images, info)
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
+
### 2. `curl` examples
|
| 107 |
+
|
| 108 |
+
When calling from `curl`, include your HF token; anonymous calls may be rate-limited or rejected.
|
| 109 |
+
|
| 110 |
+
```bash
|
| 111 |
+
export HF_TOKEN="hf_xxx..." # your Hugging Face access token
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
#### 2.1 Synchronous API – `generate_image`
|
| 115 |
+
|
| 116 |
+
```bash
|
| 117 |
+
curl -X POST "https://john6666-diffusecraftmod.hf.space/call/generate_image" \
|
| 118 |
+
-H "Authorization: Bearer $HF_TOKEN" \
|
| 119 |
+
-H "Content-Type: application/json" \
|
| 120 |
+
-d '{
|
| 121 |
+
"data": [
|
| 122 |
+
"Hello!!",
|
| 123 |
+
"lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, worst quality, low quality",
|
| 124 |
+
1,
|
| 125 |
+
28,
|
| 126 |
+
7.0,
|
| 127 |
+
0,
|
| 128 |
+
-1,
|
| 129 |
+
1024,
|
| 130 |
+
1024,
|
| 131 |
+
"votepurchase/animagine-xl-3.1",
|
| 132 |
+
"None",
|
| 133 |
+
"txt2img"
|
| 134 |
+
]
|
| 135 |
+
}'
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
#### 2.2 Streaming API – `generate_image_stream`
|
| 139 |
+
|
| 140 |
+
```bash
|
| 141 |
+
curl -X POST "https://john6666-diffusecraftmod.hf.space/call/generate_image_stream" \
|
| 142 |
+
-H "Authorization: Bearer $HF_TOKEN" \
|
| 143 |
+
-H "Content-Type: application/json" \
|
| 144 |
+
-d '{
|
| 145 |
+
"data": [
|
| 146 |
+
"Hello!!",
|
| 147 |
+
"lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, worst quality, low quality",
|
| 148 |
+
1,
|
| 149 |
+
28,
|
| 150 |
+
7.0,
|
| 151 |
+
0,
|
| 152 |
+
-1,
|
| 153 |
+
1024,
|
| 154 |
+
1024,
|
| 155 |
+
"votepurchase/animagine-xl-3.1",
|
| 156 |
+
"None",
|
| 157 |
+
"txt2img"
|
| 158 |
+
]
|
| 159 |
+
}'
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
For full parameter coverage (all advanced options), refer to the Space’s “View API” page and adapt the
|
| 163 |
+
examples above accordingly.
|