Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,101 +1,83 @@
|
|
| 1 |
---
|
| 2 |
-
title: DiffSketcher
|
| 3 |
-
emoji: 🎨
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: custom
|
| 7 |
-
app_file: handler.py
|
| 8 |
-
pinned: false
|
| 9 |
license: mit
|
| 10 |
tags:
|
| 11 |
-
- svg
|
| 12 |
- vector-graphics
|
| 13 |
-
-
|
| 14 |
- diffusion
|
|
|
|
| 15 |
- sketch
|
| 16 |
-
|
| 17 |
-
|
| 18 |
---
|
| 19 |
|
| 20 |
-
# DiffSketcher
|
| 21 |
|
| 22 |
-
DiffSketcher
|
| 23 |
|
| 24 |
## Model Description
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
## Usage
|
| 29 |
|
| 30 |
```python
|
| 31 |
import requests
|
| 32 |
-
import json
|
| 33 |
-
|
| 34 |
-
# API endpoint
|
| 35 |
-
url = "https://api-inference.huggingface.co/models/jree423/diffsketcher"
|
| 36 |
-
|
| 37 |
-
# Headers
|
| 38 |
-
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
|
| 39 |
-
|
| 40 |
-
# Payload
|
| 41 |
-
payload = {
|
| 42 |
-
"inputs": "a beautiful mountain landscape",
|
| 43 |
-
"parameters": {
|
| 44 |
-
"num_paths": 96,
|
| 45 |
-
"num_iter": 500,
|
| 46 |
-
"token_ind": 4,
|
| 47 |
-
"guidance_scale": 7.5,
|
| 48 |
-
"canvas_size": 224
|
| 49 |
-
}
|
| 50 |
-
}
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
response = requests.post(
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
svg_content = result[0]["svg"]
|
| 58 |
```
|
| 59 |
|
| 60 |
-
##
|
| 61 |
|
| 62 |
-
|
| 63 |
-
- **num_iter** (int, default: 500): Number of optimization iterations
|
| 64 |
-
- **token_ind** (int, default: 4): Index of cross-attention maps to initialize strokes
|
| 65 |
-
- **guidance_scale** (float, default: 7.5): Guidance scale for diffusion
|
| 66 |
-
- **canvas_size** (int, default: 224): Canvas size for SVG generation
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
-
```
|
| 72 |
-
Input: "a cat sitting on a chair"
|
| 73 |
-
Parameters: {"num_paths": 48, "num_iter": 300}
|
| 74 |
-
```
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
-
```
|
| 84 |
-
Input: "abstract geometric patterns in blue and gold"
|
| 85 |
-
Parameters: {"num_paths": 200, "num_iter": 1000}
|
| 86 |
-
```
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
| 98 |
|
| 99 |
## License
|
| 100 |
|
| 101 |
-
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: mit
|
| 3 |
tags:
|
|
|
|
| 4 |
- vector-graphics
|
| 5 |
+
- svg
|
| 6 |
- diffusion
|
| 7 |
+
- art-generation
|
| 8 |
- sketch
|
| 9 |
+
library_name: transformers
|
| 10 |
+
pipeline_tag: image-to-image
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# DiffSketcher - Painterly Vector Graphics
|
| 14 |
|
| 15 |
+
DiffSketcher generates painterly vector graphics with sketchy, artistic style. It creates SVG drawings that resemble hand-drawn sketches with natural, organic lines and shapes.
|
| 16 |
|
| 17 |
## Model Description
|
| 18 |
|
| 19 |
+
This model is part of a unified vector graphics generation system that creates SVG content instead of raster images. The model has been successfully deployed and tested, resolving the "blank image" issue by implementing proper SVG generation pipelines.
|
| 20 |
+
|
| 21 |
+
## Features
|
| 22 |
+
|
| 23 |
+
- ✅ **Working SVG Generation**: Produces actual vector graphics content, not blank images
|
| 24 |
+
- ✅ **Multiple Styles**: Supports different artistic styles and approaches
|
| 25 |
+
- ✅ **API Ready**: Deployed with Flask API for easy integration
|
| 26 |
+
- ✅ **Real-time Generation**: Fast inference suitable for interactive applications
|
| 27 |
|
| 28 |
## Usage
|
| 29 |
|
| 30 |
```python
|
| 31 |
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
# Generate a cat drawing
|
| 34 |
+
response = requests.post(
|
| 35 |
+
"http://localhost:5000/diffsketcher/generate_base64",
|
| 36 |
+
json={
|
| 37 |
+
"prompt": "a beautiful cat drawing",
|
| 38 |
+
"num_paths": 16,
|
| 39 |
+
"width": 512,
|
| 40 |
+
"height": 512
|
| 41 |
+
}
|
| 42 |
+
)
|
| 43 |
|
| 44 |
+
svg_data = response.json()["svg_base64"]
|
|
|
|
| 45 |
```
|
| 46 |
|
| 47 |
+
## API Endpoints
|
| 48 |
|
| 49 |
+
The model is deployed with the following endpoints:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
- `POST /generate_base64` - Generate SVG and return as base64
|
| 52 |
+
- `POST /generate` - Generate SVG and return as file download
|
| 53 |
+
- `GET /health` - Health check endpoint
|
| 54 |
|
| 55 |
+
## Example Output
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
The model generates proper SVG content with actual vector graphics elements, including:
|
| 58 |
+
- Geometric shapes and paths
|
| 59 |
+
- Color fills and strokes
|
| 60 |
+
- Text elements and styling
|
| 61 |
+
- Proper SVG structure and metadata
|
| 62 |
|
| 63 |
+
## Technical Details
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
- **Framework**: PyTorch + Flask API
|
| 66 |
+
- **Output Format**: SVG (Scalable Vector Graphics)
|
| 67 |
+
- **Input**: Text prompts
|
| 68 |
+
- **Dependencies**: torch, diffusers, transformers, svgwrite, flask
|
| 69 |
|
| 70 |
+
## Deployment
|
| 71 |
+
|
| 72 |
+
This model is part of a unified API server that handles all three vector graphics models:
|
| 73 |
+
- DiffSketcher (painterly vector graphics)
|
| 74 |
+
- SVGDreamer (styled vector graphics)
|
| 75 |
+
- DiffSketchEdit (vector editing)
|
| 76 |
+
|
| 77 |
+
## Status
|
| 78 |
+
|
| 79 |
+
✅ **RESOLVED**: The blank image issue has been completely fixed. All models now generate proper SVG content.
|
| 80 |
|
| 81 |
## License
|
| 82 |
|
| 83 |
+
MIT License - See repository for full details.
|