Spaces:
Running
on
Zero
Running
on
Zero
| title: 🧩 DiffuseCraft Mod (SDXL/SD1.5 Models Text-to-Image) | |
| emoji: 🧩🖼️📦 | |
| colorFrom: red | |
| colorTo: pink | |
| sdk: gradio | |
| sdk_version: 5.45.0 | |
| app_file: app.py | |
| pinned: true | |
| header: mini | |
| license: mit | |
| duplicated_from: r3gm/DiffuseCraft | |
| short_description: Stunning images using stable diffusion. | |
| preload_from_hub: | |
| - madebyollin/sdxl-vae-fp16-fix config.json,diffusion_pytorch_model.safetensors | |
| hf_oauth: true | |
| ## Using this Space programmatically | |
| You can call this Space from Python (via `gradio_client`) or from plain `curl`. | |
| > ⚠️ Note: This README may lag behind the actual API definition shown in the Space’s “View API” page. | |
| > If something does not work, always double-check the latest argument list and endpoint names there. | |
| Assumptions: | |
| - Space ID: `John6666/DiffuseCraftMod` | |
| - You have a valid Hugging Face access token: `hf_xxx...` (read access is enough) | |
| - Replace `hf_xxx...` with your own token | |
| --- | |
| ### 1. Python examples (`gradio_client`) | |
| Install: | |
| ```bash | |
| pip install gradio_client | |
| ```` | |
| #### 1.1 Synchronous API – `generate_image` | |
| ```python | |
| from gradio_client import Client | |
| client = Client("John6666/DiffuseCraftMod", hf_token="hf_xxx...") | |
| status, images, info = client.predict( | |
| # Core text controls | |
| prompt="Hello!!", | |
| negative_prompt=( | |
| "lowres, bad anatomy, bad hands, missing fingers, extra digit, " | |
| "fewer digits, worst quality, low quality" | |
| ), | |
| # Basic generation controls | |
| num_images=1, | |
| num_inference_steps=28, | |
| guidance_scale=7.0, | |
| clip_skip=0, | |
| seed=-1, | |
| # Canvas / model / task (optional, server has defaults) | |
| height=1024, | |
| width=1024, | |
| model_name="votepurchase/animagine-xl-3.1", | |
| vae_model="None", | |
| task="txt2img", | |
| # All other arguments are optional; defaults match the UI | |
| api_name="/generate_image", | |
| ) | |
| print(status) # e.g. "COMPLETE" | |
| print(images) # list of image paths / URLs | |
| print(info) # generation metadata (seed, model, etc.) | |
| ``` | |
| #### 1.2 Streaming API – `generate_image_stream` | |
| ```python | |
| from gradio_client import Client | |
| client = Client("John6666/DiffuseCraftMod", hf_token="hf_xxx...") | |
| job = client.submit( | |
| prompt="Hello!!", | |
| negative_prompt=( | |
| "lowres, bad anatomy, bad hands, missing fingers, extra digit, " | |
| "fewer digits, worst quality, low quality" | |
| ), | |
| num_images=1, | |
| num_inference_steps=28, | |
| guidance_scale=7.0, | |
| clip_skip=0, | |
| seed=-1, | |
| height=1024, | |
| width=1024, | |
| model_name="votepurchase/animagine-xl-3.1", | |
| vae_model="None", | |
| task="txt2img", | |
| api_name="/generate_image_stream", | |
| ) | |
| for status, images, info in job: | |
| # You will see progress messages, intermediate previews, and the final result. | |
| print(status, images, info) | |
| ``` | |
| You can stop iterating once you see a `"COMPLETE"` status if you only care about the final output. | |
| --- | |
| ### 2. `curl` examples | |
| When calling from `curl`, include your HF token; anonymous calls may be rate-limited or rejected. | |
| ```bash | |
| export HF_TOKEN="hf_xxx..." # your Hugging Face access token | |
| ``` | |
| The `data` field is a positional array. The order must match the function signature. | |
| For simplicity, the examples below only send the first few arguments and rely on server defaults for the rest. | |
| #### 2.1 Synchronous API – `generate_image` | |
| ```bash | |
| curl -X POST "https://john6666-diffusecraftmod.hf.space/call/generate_image" \ | |
| -H "Authorization: Bearer $HF_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "data": [ | |
| "Hello!!", // prompt | |
| "lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, worst quality, low quality", // negative_prompt | |
| 1, // num_images | |
| 28, // num_inference_steps | |
| 7.0, // guidance_scale | |
| 0, // clip_skip | |
| -1 // seed | |
| // All subsequent parameters will use their default values | |
| ] | |
| }' | |
| ``` | |
| #### 2.2 Streaming API – `generate_image_stream` | |
| ```bash | |
| curl -X POST "https://john6666-diffusecraftmod.hf.space/call/generate_image_stream" \ | |
| -H "Authorization: Bearer $HF_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "data": [ | |
| "Hello!!", | |
| "lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, worst quality, low quality", | |
| 1, | |
| 28, | |
| 7.0, | |
| 0, | |
| -1 | |
| ] | |
| }' | |
| ``` | |
| For full parameter coverage (all advanced options such as LoRAs, ControlNet, IP-Adapter, etc.), | |
| refer to the Space’s “View API” page and adapt the examples above accordingly. | |