File size: 1,348 Bytes
1b3876a
 
 
 
 
 
 
 
 
 
 
54e8ea7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
title: StickerGen
emoji: 🚀
colorFrom: indigo
colorTo: pink
sdk: docker
pinned: false
---



# Hugging Face Space: Image to Chibi/Anime/Cartoon Sticker Generator

This Space provides an API endpoint `/generate` that:
1. Accepts an image and a style (chibi, anime, cartoon, etc.).
2. Captions the image using BLIP.
3. Constructs a DALL·E 3 prompt and calls OpenAI's API to generate a set of stickers.
4. Returns the generated sticker image URL.

## Flow (Numbered)
1. **User uploads an image** (`image`) and specifies a sticker style (`style`).
2. **App generates a caption** using BLIP (image captioning).
3. **App constructs a DALL·E 3 prompt** combining the style and generated caption.
4. **App sends the prompt to OpenAI DALL·E 3** and retrieves a sticker image URL.
5. **App returns a JSON** containing the caption, prompt, and image URL.

## Usage

### POST `/generate`
- `image`: (file, required) — Input image (JPEG/PNG).
- `style`: (text, optional, default: "chibi") — Sticker style ("chibi", "anime", "cartoon", etc.).

#### Response
```json
{
  "caption": "...",
  "prompt": "...",
  "image_url": "..."
}
```

### Requirements
- Hugging Face installs dependencies from `requirements.txt`
- Set your OpenAI API key as environment variable:  
  `OPENAI_API_KEY=sk-...`

### Running locally
```bash
uvicorn app:app --reload
```