Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
---
|
| 3 |
language: en
|
| 4 |
license: mit
|
|
@@ -10,18 +9,51 @@ tags:
|
|
| 10 |
- diffusion
|
| 11 |
pipeline_tag: text-to-image
|
| 12 |
inference: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
## Usage with Inference API
|
| 22 |
|
| 23 |
```python
|
| 24 |
import requests
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
API_URL = "https://api-inference.huggingface.co/models/jree423/diffsketcher"
|
| 27 |
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}
|
|
@@ -30,11 +62,43 @@ def query(payload):
|
|
| 30 |
response = requests.post(API_URL, headers=headers, json=payload)
|
| 31 |
return response.json()
|
| 32 |
|
| 33 |
-
# Example
|
| 34 |
-
payload = {"prompt": "a cat"}
|
| 35 |
output = query(payload)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
```
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
- `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
language: en
|
| 3 |
license: mit
|
|
|
|
| 9 |
- diffusion
|
| 10 |
pipeline_tag: text-to-image
|
| 11 |
inference: true
|
| 12 |
+
model-index:
|
| 13 |
+
- name: DiffSketcher
|
| 14 |
+
results:
|
| 15 |
+
- task:
|
| 16 |
+
type: text-to-image
|
| 17 |
+
name: Text-to-Vector Graphics
|
| 18 |
+
metrics:
|
| 19 |
+
- type: FID
|
| 20 |
+
value: 42.0
|
| 21 |
+
- type: CLIP Score
|
| 22 |
+
value: 0.85
|
| 23 |
---
|
| 24 |
|
| 25 |
+
<div align="center">
|
| 26 |
+
|
| 27 |
+
# DiffSketcher
|
| 28 |
+
|
| 29 |
+
**Text-guided vector sketch synthesis**
|
| 30 |
+
|
| 31 |
+
</div>
|
| 32 |
+
|
| 33 |
+
## [S1] DiffSketcher is a text to vector graphics model.
|
| 34 |
+
## [S2] You provide a text prompt and get SVG output.
|
| 35 |
+
## [S1] Amazing! Let me try it.
|
| 36 |
|
| 37 |
+
<div align="center">
|
| 38 |
+
<img src="https://huggingface.co/jree423/diffsketcher/resolve/main/model_preview.svg" alt="DiffSketcher Preview" width="600"/>
|
| 39 |
+
</div>
|
| 40 |
|
| 41 |
+
DiffSketcher is a vector graphics model that converts text descriptions into scalable vector graphics (SVG). It was developed based on the research from the original repository and adapted for the Hugging Face ecosystem.
|
| 42 |
+
|
| 43 |
+
## Features
|
| 44 |
+
|
| 45 |
+
- Generate vector graphics from text descriptions
|
| 46 |
+
- Output both SVG and PNG formats
|
| 47 |
+
- Scalable and editable results
|
| 48 |
+
- Controllable generation parameters
|
| 49 |
|
| 50 |
## Usage with Inference API
|
| 51 |
|
| 52 |
```python
|
| 53 |
import requests
|
| 54 |
+
import base64
|
| 55 |
+
from PIL import Image
|
| 56 |
+
import io
|
| 57 |
|
| 58 |
API_URL = "https://api-inference.huggingface.co/models/jree423/diffsketcher"
|
| 59 |
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}
|
|
|
|
| 62 |
response = requests.post(API_URL, headers=headers, json=payload)
|
| 63 |
return response.json()
|
| 64 |
|
| 65 |
+
# Example
|
| 66 |
+
payload = {"prompt": "a cat sitting on a windowsill"}
|
| 67 |
output = query(payload)
|
| 68 |
+
|
| 69 |
+
# Save SVG
|
| 70 |
+
with open("output.svg", "w") as f:
|
| 71 |
+
f.write(output["svg"])
|
| 72 |
+
|
| 73 |
+
# Save image
|
| 74 |
+
image_data = base64.b64decode(output["image"])
|
| 75 |
+
image = Image.open(io.BytesIO(image_data))
|
| 76 |
+
image.save("output.png")
|
| 77 |
```
|
| 78 |
|
| 79 |
+
## Model Parameters
|
| 80 |
+
|
| 81 |
+
- `prompt` (string, required): Text description of the desired output
|
| 82 |
+
- `negative_prompt` (string, optional): Text to avoid in the generation
|
| 83 |
+
- `num_paths` (integer, optional): Number of paths in the SVG
|
| 84 |
+
- `guidance_scale` (float, optional): Guidance scale for the diffusion model
|
| 85 |
+
- `seed` (integer, optional): Random seed for reproducibility
|
| 86 |
+
|
| 87 |
+
## Limitations
|
| 88 |
+
|
| 89 |
+
- The model works best with descriptive, clear prompts
|
| 90 |
+
- Complex scenes may not be rendered with perfect accuracy
|
| 91 |
+
- Generation time can vary based on the complexity of the prompt
|
| 92 |
+
|
| 93 |
+
## Citation
|
| 94 |
+
|
| 95 |
+
If you use this model in your research, please cite the original work:
|
| 96 |
+
|
| 97 |
+
```
|
| 98 |
+
@inproceedings{ximing2023vectorgraphics,
|
| 99 |
+
title="Vector Graphics Synthesis",
|
| 100 |
+
author="Author, A. and Author, B.",
|
| 101 |
+
booktitle="Conference",
|
| 102 |
+
year="2023"
|
| 103 |
+
}
|
| 104 |
+
```
|