cooper0914 commited on
Commit
05f137b
Β·
verified Β·
1 Parent(s): a541bff

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +132 -121
README.md CHANGED
@@ -1,122 +1,133 @@
1
- # 🎨 CycleGAN Face-Sketch Converter
2
-
3
- Convert face photos to sketches and vice versa using CycleGAN.
4
-
5
- ## πŸš€ Deployment on Hugging Face Spaces
6
-
7
- ### Step 1: Prepare Your Models
8
-
9
- After training, run this cell in your notebook:
10
-
11
- ```python
12
- # Run this in your training notebook
13
- export_for_huggingface(checkpoint_epoch=100) # Replace 100 with your best epoch
14
- ```
15
-
16
- This creates two files in `deployment_models/`:
17
- - `photo_to_sketch.pth` (~44 MB)
18
- - `sketch_to_photo.pth` (~44 MB)
19
-
20
- ### Step 2: Create Hugging Face Space
21
-
22
- 1. Go to [Hugging Face Spaces](https://huggingface.co/spaces)
23
- 2. Click **"Create new Space"**
24
- 3. Configure:
25
- - **Space name**: `cyclegan-face-sketch`
26
- - **License**: Choose appropriate license
27
- - **Select SDK**: **Streamlit**
28
- - **Space hardware**: CPU Basic (free) or GPU for faster inference
29
-
30
- ### Step 3: Upload Files
31
-
32
- Upload these files to your Space:
33
-
34
- ```
35
- your-space/
36
- β”œβ”€β”€ app.py # Streamlit application
37
- β”œβ”€β”€ requirements.txt # Python dependencies
38
- β”œβ”€β”€ photo_to_sketch.pth # Model file (Photo β†’ Sketch)
39
- β”œβ”€β”€ sketch_to_photo.pth # Model file (Sketch β†’ Photo)
40
- └── README.md # This file (optional)
41
- ```
42
-
43
- ### Step 4: Your Space will Auto-Build
44
-
45
- Hugging Face will automatically:
46
- 1. Install dependencies from `requirements.txt`
47
- 2. Run your Streamlit app
48
- 3. Provide a public URL
49
-
50
- ## πŸ“¦ File Sizes
51
-
52
- - `photo_to_sketch.pth`: ~44 MB
53
- - `sketch_to_photo.pth`: ~44 MB
54
- - **Total**: ~88 MB (well within free tier limits)
55
-
56
- ## 🎯 Features
57
-
58
- - βœ… Photo to Sketch conversion
59
- - βœ… Sketch to Photo conversion
60
- - βœ… Auto-detection of input type
61
- - βœ… Camera input support
62
- - βœ… Download results
63
- - βœ… Responsive UI
64
-
65
- ## πŸ’‘ Usage Tips
66
-
67
- ### For Best Results:
68
- - Use clear, front-facing photos
69
- - Ensure good lighting
70
- - Images are automatically resized to 256x256
71
-
72
- ### Hardware:
73
- - **CPU Basic (Free)**: ~3-5 seconds per image
74
- - **GPU T4 (Paid)**: ~0.5 seconds per image
75
-
76
- ## πŸ”§ Local Testing
77
-
78
- Before deploying, test locally:
79
-
80
- ```bash
81
- # Install dependencies
82
- pip install -r requirements.txt
83
-
84
- # Run Streamlit app
85
- streamlit run app.py
86
- ```
87
-
88
- Then open http://localhost:8501
89
-
90
- ## πŸ“Š Model Details
91
-
92
- - **Architecture**: CycleGAN with ResNet-based generators
93
- - **Input Size**: 256x256 RGB images
94
- - **Training**: Unpaired face-sketch dataset
95
- - **Loss Functions**:
96
- - Adversarial loss (LSGAN)
97
- - Cycle consistency loss
98
- - Identity loss
99
-
100
- ## πŸ› Troubleshooting
101
-
102
- ### Space doesn't start:
103
- - Check all files are uploaded correctly
104
- - Verify file names match exactly in `app.py`
105
- - Check Space logs for errors
106
-
107
- ### Out of memory:
108
- - Use CPU Basic hardware
109
- - Models are optimized for CPU inference
110
-
111
- ### Slow inference:
112
- - Upgrade to GPU hardware in Space settings
113
- - Or use batch processing
114
-
115
- ## πŸ“ License
116
-
117
- [Your License Here]
118
-
119
- ## πŸ™ Acknowledgments
120
-
121
- - CycleGAN paper: [Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks](https://arxiv.org/abs/1703.10593)
 
 
 
 
 
 
 
 
 
 
 
122
  - Person Face Sketches dataset: [Kaggle](https://www.kaggle.com/datasets/almightyj/person-face-sketches)
 
1
+ ---
2
+ title: CycleGAN Face-Sketch Converter
3
+ emoji: 🎨
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: "1.28.0"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # 🎨 CycleGAN Face-Sketch Converter
13
+
14
+ Convert face photos to sketches and vice versa using CycleGAN.
15
+
16
+ ## πŸš€ Deployment on Hugging Face Spaces
17
+
18
+ ### Step 1: Prepare Your Models
19
+
20
+ After training, run this cell in your notebook:
21
+
22
+ ```python
23
+ # Run this in your training notebook
24
+ export_for_huggingface(checkpoint_epoch=100) # Replace 100 with your best epoch
25
+ ```
26
+
27
+ This creates two files in `deployment_models/`:
28
+ - `photo_to_sketch.pth` (~44 MB)
29
+ - `sketch_to_photo.pth` (~44 MB)
30
+
31
+ ### Step 2: Create Hugging Face Space
32
+
33
+ 1. Go to [Hugging Face Spaces](https://huggingface.co/spaces)
34
+ 2. Click **"Create new Space"**
35
+ 3. Configure:
36
+ - **Space name**: `cyclegan-face-sketch`
37
+ - **License**: Choose appropriate license
38
+ - **Select SDK**: **Streamlit**
39
+ - **Space hardware**: CPU Basic (free) or GPU for faster inference
40
+
41
+ ### Step 3: Upload Files
42
+
43
+ Upload these files to your Space:
44
+
45
+ ```
46
+ your-space/
47
+ β”œβ”€β”€ app.py # Streamlit application
48
+ β”œβ”€β”€ requirements.txt # Python dependencies
49
+ β”œβ”€β”€ photo_to_sketch.pth # Model file (Photo β†’ Sketch)
50
+ β”œβ”€β”€ sketch_to_photo.pth # Model file (Sketch β†’ Photo)
51
+ └── README.md # This file (optional)
52
+ ```
53
+
54
+ ### Step 4: Your Space will Auto-Build
55
+
56
+ Hugging Face will automatically:
57
+ 1. Install dependencies from `requirements.txt`
58
+ 2. Run your Streamlit app
59
+ 3. Provide a public URL
60
+
61
+ ## πŸ“¦ File Sizes
62
+
63
+ - `photo_to_sketch.pth`: ~44 MB
64
+ - `sketch_to_photo.pth`: ~44 MB
65
+ - **Total**: ~88 MB (well within free tier limits)
66
+
67
+ ## 🎯 Features
68
+
69
+ - βœ… Photo to Sketch conversion
70
+ - βœ… Sketch to Photo conversion
71
+ - βœ… Auto-detection of input type
72
+ - βœ… Camera input support
73
+ - βœ… Download results
74
+ - βœ… Responsive UI
75
+
76
+ ## πŸ’‘ Usage Tips
77
+
78
+ ### For Best Results:
79
+ - Use clear, front-facing photos
80
+ - Ensure good lighting
81
+ - Images are automatically resized to 256x256
82
+
83
+ ### Hardware:
84
+ - **CPU Basic (Free)**: ~3-5 seconds per image
85
+ - **GPU T4 (Paid)**: ~0.5 seconds per image
86
+
87
+ ## πŸ”§ Local Testing
88
+
89
+ Before deploying, test locally:
90
+
91
+ ```bash
92
+ # Install dependencies
93
+ pip install -r requirements.txt
94
+
95
+ # Run Streamlit app
96
+ streamlit run app.py
97
+ ```
98
+
99
+ Then open http://localhost:8501
100
+
101
+ ## πŸ“Š Model Details
102
+
103
+ - **Architecture**: CycleGAN with ResNet-based generators
104
+ - **Input Size**: 256x256 RGB images
105
+ - **Training**: Unpaired face-sketch dataset
106
+ - **Loss Functions**:
107
+ - Adversarial loss (LSGAN)
108
+ - Cycle consistency loss
109
+ - Identity loss
110
+
111
+ ## πŸ› Troubleshooting
112
+
113
+ ### Space doesn't start:
114
+ - Check all files are uploaded correctly
115
+ - Verify file names match exactly in `app.py`
116
+ - Check Space logs for errors
117
+
118
+ ### Out of memory:
119
+ - Use CPU Basic hardware
120
+ - Models are optimized for CPU inference
121
+
122
+ ### Slow inference:
123
+ - Upgrade to GPU hardware in Space settings
124
+ - Or use batch processing
125
+
126
+ ## πŸ“ License
127
+
128
+ [Your License Here]
129
+
130
+ ## πŸ™ Acknowledgments
131
+
132
+ - CycleGAN paper: [Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks](https://arxiv.org/abs/1703.10593)
133
  - Person Face Sketches dataset: [Kaggle](https://www.kaggle.com/datasets/almightyj/person-face-sketches)