Kutluhan commited on
Commit
4bb97ac
·
1 Parent(s): 5e56207

README updated

Browse files
Files changed (6) hide show
  1. README.md +140 -1
  2. images/out1.png +3 -0
  3. images/out2.png +3 -0
  4. images/out3.png +3 -0
  5. images/out4.png +3 -0
  6. images/out5.png +3 -0
README.md CHANGED
@@ -10,4 +10,143 @@ pinned: false
10
  license: unknown
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  license: unknown
11
  ---
12
 
13
+ # Semantic Inpainting
14
+
15
+ **Semantic-Aware Image-to-Image Generation Using Diffusion Models for Urban Satellite Imagery**
16
+
17
+ A Gradio-based web app that lets you interactively mask and reconstruct regions of high-resolution urban satellite images. Under the hood, a latent diffusion model conditioned on semantic segmentation labels ensures that buildings, roads, forests, and other classes are inpainted in a contextually coherent and visually realistic way.
18
+
19
+ ---
20
+
21
+ Link to the GitHub repository - [GitHub](https://github.com/kbuyukburc/SemanticInpaint)<br />
22
+ Link to the Hugging Face (HF) demo - [Hugging Face](https://huggingface.co/spaces/Kutluhan/SemanticInpaint)
23
+
24
+ ## Features
25
+
26
+ - **Interactive Gradio GUI**
27
+ - Upload or select example satellite images
28
+ - Free-hand drawing mask regions
29
+ - Semantic label selector with color preview
30
+ - Adjustable guidance scale for faithfulness to labels
31
+ - Choose number of outputs to generate
32
+ - **High-quality Inpainting**
33
+ - Latent diffusion conditioned on segmentation maps
34
+ - Supports common urban classes: buildings, roads, vegetation, water, etc.
35
+ - **Flexible Workflow**
36
+ - View original and inpainted images
37
+ - Download and save outputs
38
+ - “Use Output as New Input” button for iterative edits
39
+
40
+ ---
41
+
42
+ ## Getting Started
43
+
44
+ ### Prerequisites
45
+
46
+ - Python >= 3.10
47
+ - git
48
+ - A CUDA-capable GPU (recommended for performance)
49
+
50
+
51
+ ### Installation on local computer or using Google Colab or Kaggle with GPU (Preferred)
52
+
53
+ 1. **Clone the HF repository**
54
+ ```bash
55
+ git clone https://huggingface.co/spaces/Kutluhan/SemanticInpaint
56
+ cd SemanticInpaint
57
+ ```
58
+
59
+ 2. **Install Python dependencies**
60
+ ```bash
61
+ pip install -r requirements.txt
62
+ pip install gradio
63
+ ```
64
+
65
+ ### Run it directly on Hugging Face Spaces
66
+ 1. **Visit to HF Spaces page using the [Link](https://huggingface.co/spaces/Kutluhan/SemanticInpaint)**
67
+ ```bash
68
+ https://huggingface.co/spaces/Kutluhan/SemanticInpaint
69
+ ```
70
+
71
+ 2. **Create an account (requires PRO account for extra Zero-gpu credits) and run it directly (Skip Usage part 1)**
72
+ ---
73
+
74
+ ## Usage
75
+
76
+ 1. **Launch the app**
77
+ ```bash
78
+ python app.py
79
+ ```
80
+ By default, Gradio will run on the public URL.<br />
81
+ You can also select which pre trained model you want to use (default model008000.pt, fintuned on 30 epocs), available [here](https://huggingface.co/Kutluhan/SemanticInpaint/tree/main).<br />
82
+ The pre-trained model can be changed in the app.py file.
83
+
84
+ 2. **In your browser**
85
+ - **Input Panel**: Upload or pick an urban satellite image from examples.
86
+ - **Masking & Control Panel**:
87
+ - Draw to mask regions.
88
+ - Select semantic class (e.g., Building, Road, Vegetation).
89
+ - Adjust **Thickness Scale** for how strictly to follow labels.
90
+ - Choose **Number of Images** to generate.
91
+ - **Output Panel**:
92
+ - Compare original v/s. inpainted images.
93
+ - Download and save the output images or re-feed it for another pass.
94
+
95
+ ---
96
+
97
+ ## Sample Outputs
98
+ Here are some sample outputs based on our testing --<br />
99
+ - Imagine you want to create new town with wider roads going through a forest<br />
100
+ ![out1](images/out1.png)<br />
101
+
102
+ - Imagine you want to create land for permanent crops in a small town<br />
103
+ ![out2](images/out2.png)<br />
104
+
105
+ - Imagine you want to create a new city in middle of nowhere that doesn't have any buildings, so you start with building roads<br />
106
+ ![out3](images/out3.png)<br />
107
+
108
+ - Imagine you want create land for herbaceous vegetation in a crowded city<br />
109
+ ![out4](images/out4.png)<br />
110
+
111
+ - Imagine there was a lot of rain in a particular area leading to water deposits and wetland formation, so you want to create a bridge connecting the two seperated villages<br />
112
+ ![out5](images/out5.png)<br />
113
+
114
+
115
+
116
+
117
+ ## Recommendations and Insights
118
+
119
+ ### General Recommendations
120
+ - **Generate Multiple Samples**: When using the tool, generate 2 to 4 samples to explore different variations. Not all outputs are visually satisfying, so generating multiple samples increases the chance of obtaining a high-quality, contextually appropriate result.
121
+
122
+ ### Label Behavior Insights
123
+ - **Multi-Label Combinations That Work Well**
124
+ - **Urban Fabric**: Tends to generate city-like structures and dense urban layouts.
125
+ - **Industrial/Commercial**: Often produces road networks and industrial complexes. Users should preferably draw thin lines to simulate roads when using this label.
126
+ - **Permanent Crops**: Generates brown or green agricultural fields.
127
+ - **Forests**: Creates dense forested regions.
128
+ - **Water**: Primarily generates lakes (greenish color) and occasionally seas (bluish color).
129
+ - **Artificial Non-Agricultural Vegetated Areas**: Complements urban layouts.
130
+
131
+ - **Labels That Work Well Alone**
132
+ - **Pastures**: Best used independently.
133
+ - **Arable Land**: Works well individually.
134
+ - **Herbaceous Vegetation**: Generates vegetation but sometimes generates white snowy textures.
135
+
136
+ - **Labels That Do Not Perform Well**
137
+ - **Mine/Dump/Construction**: Limited generation quality due to insufficient training data.
138
+ - **Complex & Mixed Cultivation Patterns**: Inconsistent variation causes inconsistent results.
139
+ - **Orchards**: insufficent training data.
140
+ - **Open Spaces with Little or No Vegetation**: Sparse or incoherent generation.
141
+
142
+ - **Recommended Combinations**
143
+ - **Wetlands + Water**: Generates more realistic transitions.
144
+ - **Urban Fabric + Industrial/Commercial**: This combination generates city layouts with roads, creating realistic urban environments.
145
+
146
+ ## Best Practices for Using the Tool
147
+ - **Use Few Classes at a Time**: Pick 1–2 semantic classes initially, draw them on the mask, and generate images.
148
+ - **Iterative Editing**: Select the best image from the generated samples as the new base, then add 1–2 more semantic classes and repeat the generation process.
149
+ - **Preserve Context**: Using only 1–2 new mask types at a time helps maintain better visual and semantic context in the generated images.
150
+ - **Avoid Large Masks**: Drawing very large masks disrupts spatial coherence. Prefer smaller, targeted edits to preserve surrounding context and improve the realism of generated outputs.
151
+ ---
152
+
images/out1.png ADDED

Git LFS Details

  • SHA256: 04f4b57f145c103e761c2858689b3fbf5f5f1f70ebc593f954e462692fa2d434
  • Pointer size: 131 Bytes
  • Size of remote file: 443 kB
images/out2.png ADDED

Git LFS Details

  • SHA256: f7f475e6280bc17285f1e907bd903e470f32b202d86fbf5db693e1895e788745
  • Pointer size: 131 Bytes
  • Size of remote file: 590 kB
images/out3.png ADDED

Git LFS Details

  • SHA256: c0aad7ef36b7ea71d7228f87c5cc79f7749374214029982332f3a74ec0687ea7
  • Pointer size: 131 Bytes
  • Size of remote file: 663 kB
images/out4.png ADDED

Git LFS Details

  • SHA256: 1372b5421238ac54c71ca0d2158dfd35b790ac27d658c1c8833c790daa16eafb
  • Pointer size: 131 Bytes
  • Size of remote file: 794 kB
images/out5.png ADDED

Git LFS Details

  • SHA256: 4daa0addfeb9e2a9f96cc022eb99ac65e37bc0db9fe4bdfd36fb776221383b10
  • Pointer size: 131 Bytes
  • Size of remote file: 620 kB