CoolFace
Modelpublic

jree423/diffsketcher

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes42downloads
README.md125 linesDownload Raw Back to root
1---2title: DiffSketcher3emoji: 🎨4colorFrom: blue5colorTo: purple6sdk: custom7app_file: handler.py8pinned: false9license: mit10tags:11- text-to-svg12- vector-graphics13- diffusion14- sketch15- art16pipeline_tag: text-to-image17---18 19# DiffSketcher: Text Guided Vector Sketch Synthesis20 21DiffSketcher is a novel method for generating high-quality vector sketches from text prompts using latent diffusion models. This model can create artistic SVG representations based on natural language descriptions.22 23## Model Description24 25DiffSketcher leverages the power of Stable Diffusion to guide the generation of vector graphics. The model optimizes SVG paths to match the semantic content described in the input text while maintaining the artistic quality of hand-drawn sketches.26 27## Usage28 29### Direct API Call30 31```python32import requests33 34API_URL = "https://api-inference.huggingface.co/models/jree423/diffsketcher"35headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}36 37def query(payload):38    response = requests.post(API_URL, headers=headers, json=payload)39    return response.json()40 41output = query({42    "inputs": "a beautiful mountain landscape",43    "parameters": {44        "num_paths": 96,45        "num_iter": 500,46        "guidance_scale": 7.5,47        "width": 224,48        "height": 224,49        "seed": 4250    }51})52```53 54### Using the Inference Client55 56```python57from huggingface_hub import InferenceClient58 59client = InferenceClient("jree423/diffsketcher")60result = client.post(61    json={62        "inputs": "a cat sitting on a windowsill",63        "parameters": {64            "num_paths": 128,65            "guidance_scale": 8.066        }67    }68)69```70 71## Parameters72 73- **num_paths** (int, default: 96): Number of SVG paths to generate. More paths create more detailed sketches.74- **num_iter** (int, default: 500): Number of optimization iterations. More iterations improve quality but take longer.75- **guidance_scale** (float, default: 7.5): Controls how closely the generation follows the text prompt.76- **width** (int, default: 224): Output SVG width in pixels.77- **height** (int, default: 224): Output SVG height in pixels.78- **seed** (int, default: 42): Random seed for reproducible results.79 80## Output Format81 82The model returns a JSON object containing:83- `svg`: The generated SVG content as a string84- `svg_base64`: Base64 encoded SVG for easy transmission85- `prompt`: The input text prompt86- `parameters`: The parameters used for generation87 88## Examples89 90### Simple Objects91- "a red apple"92- "a flying bird"93- "a vintage car"94 95### Complex Scenes96- "a mountain landscape with trees"97- "a city skyline at sunset"98- "a garden with flowers and butterflies"99 100### Artistic Styles101- "a portrait in the style of Van Gogh"102- "minimalist line drawing of a face"103- "abstract geometric patterns"104 105## Technical Details106 107- **Base Model**: Stable Diffusion 2.1108- **Framework**: PyTorch + Diffusers109- **Vector Rendering**: DiffVG (differentiable vector graphics)110- **Optimization**: Adam optimizer with custom learning rates for different SVG parameters111 112## Citation113 114```bibtex115@inproceedings{xing2023diffsketcher,116  title={DiffSketcher: Text Guided Vector Sketch Synthesis through Latent Diffusion Models},117  author={Xing, XiMing and others},118  booktitle={NeurIPS},119  year={2023}120}121```122 123## License124 125This model is released under the MIT License.