File size: 2,256 Bytes
1221014
 
 
 
 
 
ffe870b
1221014
 
 
ffe870b
1221014
e2750f5
1221014
 
 
 
 
 
 
 
e2750f5
1221014
 
e2750f5
1221014
 
 
ffe870b
e2750f5
 
 
 
4bd7b20
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is a Hugging Face Spaces application that generates images in Pablo Picasso's cubist style using the FLUX.1-dev model from Black Forest Labs. The app uses Gradio to create a web interface with ZeroGPU acceleration for high-quality text-to-image generation.

## Architecture

- **app.py**: Gradio application using FLUX.1-dev for Picasso-style image generation
- **README.md**: Hugging Face Spaces configuration file with metadata (title, emoji, SDK version, etc.)
- **requirements.txt**: Python dependencies including PyTorch, Diffusers, and Gradio
- **.gitattributes**: Git LFS configuration for handling large model files and binary assets

## Key Commands

### Running the Application
```bash
python app.py
```
This launches the Gradio interface locally for testing (requires GPU).

### Hugging Face Spaces Deployment
The app is automatically deployed to Hugging Face Spaces with ZeroGPU. Changes to `app.py` will trigger redeployment.

## Development Notes

- Uses **FLUX.1-dev** model from Black Forest Labs for high-quality text-to-image generation
- **@spaces.GPU decorators** are required for ZeroGPU compatibility
- Model runs in **bfloat16** precision for optimal performance on H200 GPUs
- Output resolution is **1024x1024** pixels
- Optimal parameters: 28 inference steps, guidance scale 3.5
- Prompt enhancement automatically adds Picasso-style descriptors

## Code Architecture

### Core Components
- **Model Loading**: `load_model()` function initializes FLUX.1-dev pipeline with bfloat16 precision
- **Image Generation**: `generate_image()` function handles prompt enhancement and image generation with configurable parameters
- **UI Interface**: Gradio Blocks layout with prompt input, parameter sliders, and example buttons
- **Example System**: Pre-defined example prompts accessible through vertical button layout

### Key Functions
- `load_model()` (app.py:9): Loads and configures the FLUX.1-dev pipeline
- `generate_image()` (app.py:27): Main generation function with Picasso-style prompt enhancement
- Example setter functions (app.py:88-97): Populate prompt input with predefined examples