Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -1,59 +1,10 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
base_model: runwayml/stable-diffusion-v1-5
|
4 |
-
tags:
|
5 |
-
- text-to-image
|
6 |
-
- diffusers
|
7 |
-
- vector-graphics
|
8 |
-
- svg
|
9 |
-
- sketch
|
10 |
-
- stable-diffusion
|
11 |
-
pipeline_tag: text-to-image
|
12 |
-
inference: true
|
13 |
-
---
|
14 |
|
15 |
-
#
|
16 |
|
17 |
-
This is a
|
18 |
-
|
19 |
-
## Model Description
|
20 |
-
|
21 |
-
DiffSketcher is a novel approach to generate SVG sketches from text prompts. It uses a differentiable rasterizer to optimize SVG parameters based on text-to-image diffusion models.
|
22 |
|
23 |
## Usage
|
24 |
|
25 |
-
You can use this model directly with the Hugging Face Diffusers library:
|
26 |
-
|
27 |
-
```python
|
28 |
-
from diffusers import DiffusionPipeline
|
29 |
-
|
30 |
-
pipeline = DiffusionPipeline.from_pretrained("jree423/diffsketcher")
|
31 |
-
output = pipeline(
|
32 |
-
prompt="A beautiful sunset over the mountains",
|
33 |
-
negative_prompt="ugly, blurry",
|
34 |
-
num_paths=96,
|
35 |
-
token_ind=4,
|
36 |
-
num_iter=800,
|
37 |
-
guidance_scale=7.5,
|
38 |
-
width=1.5,
|
39 |
-
seed=42
|
40 |
-
)
|
41 |
-
|
42 |
-
# Access the generated SVG
|
43 |
-
svg = output.svg
|
44 |
-
|
45 |
-
# Access the rendered image
|
46 |
-
image = output.images[0]
|
47 |
-
|
48 |
-
# Save the SVG
|
49 |
-
with open("output.svg", "w") as f:
|
50 |
-
f.write(svg)
|
51 |
-
```
|
52 |
-
|
53 |
-
## Inference API Usage
|
54 |
-
|
55 |
-
You can use this model directly with the Hugging Face Inference API:
|
56 |
-
|
57 |
```python
|
58 |
import requests
|
59 |
|
@@ -64,40 +15,5 @@ def query(payload):
|
|
64 |
response = requests.post(API_URL, headers=headers, json=payload)
|
65 |
return response.json()
|
66 |
|
67 |
-
output = query({
|
68 |
-
"prompt": "A beautiful sunset over the mountains",
|
69 |
-
"negative_prompt": "ugly, blurry",
|
70 |
-
"num_paths": 96,
|
71 |
-
"token_ind": 4,
|
72 |
-
"num_iter": 800,
|
73 |
-
"guidance_scale": 7.5,
|
74 |
-
"width": 1.5,
|
75 |
-
"seed": 42
|
76 |
-
})
|
77 |
```
|
78 |
-
|
79 |
-
## Parameters
|
80 |
-
|
81 |
-
- `prompt` (str): The text prompt to guide the sketch generation
|
82 |
-
- `negative_prompt` (str, optional): The prompt not to guide the sketch generation
|
83 |
-
- `num_paths` (int, default=96): Number of SVG paths to generate
|
84 |
-
- `token_ind` (int, default=4): Token index for attention control
|
85 |
-
- `num_iter` (int, default=800): Number of optimization iterations
|
86 |
-
- `guidance_scale` (float, default=7.5): Scale for classifier-free guidance
|
87 |
-
- `width` (float, default=1.5): Width of the SVG paths
|
88 |
-
- `seed` (int, optional): Random seed for reproducibility
|
89 |
-
|
90 |
-
## Limitations
|
91 |
-
|
92 |
-
This is a simplified implementation of DiffSketcher for demonstration purposes. For the full implementation, please refer to the [original repository](https://github.com/ximinng/DiffSketcher).
|
93 |
-
|
94 |
-
## Citation
|
95 |
-
|
96 |
-
```bibtex
|
97 |
-
@article{xing2023diffsketcher,
|
98 |
-
title={DiffSketcher: Text Guided Vector Sketch Synthesis through Latent Diffusion Models},
|
99 |
-
author={Xing, Ximing and Xie, Chuang and Yang, Yinghao and Li, Shiyin and Jia, Xu and Qiao, Yu},
|
100 |
-
journal={arXiv preprint arXiv:2306.14685},
|
101 |
-
year={2023}
|
102 |
-
}
|
103 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
+
# Diffsketcher
|
3 |
|
4 |
+
This is a simplified implementation of Diffsketcher for the Hugging Face Inference API.
|
|
|
|
|
|
|
|
|
5 |
|
6 |
## Usage
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
```python
|
9 |
import requests
|
10 |
|
|
|
15 |
response = requests.post(API_URL, headers=headers, json=payload)
|
16 |
return response.json()
|
17 |
|
18 |
+
output = query({"prompt": "a cat"})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|