Spaces:
Running
on
Zero
Running
on
Zero
Jagrut Thakare
commited on
Commit
·
238009c
1
Parent(s):
b335f13
v1
Browse files- .gitattributes +4 -5
- SDXL_inpaint.ipynb +475 -0
- app.py +115 -0
- requirements.txt +10 -0
.gitattributes
CHANGED
@@ -2,13 +2,11 @@
|
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
@@ -16,20 +14,21 @@
|
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
*.pkl filter=lfs diff=lfs merge=lfs -text
|
|
|
22 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
|
|
5 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
|
|
10 |
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
|
|
14 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
|
|
17 |
*.pickle filter=lfs diff=lfs merge=lfs -text
|
18 |
*.pkl filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
|
|
23 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
25 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
26 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
27 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
28 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
SDXL_inpaint.ipynb
ADDED
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"nbformat": 4,
|
3 |
+
"nbformat_minor": 0,
|
4 |
+
"metadata": {
|
5 |
+
"colab": {
|
6 |
+
"provenance": [],
|
7 |
+
"gpuType": "T4"
|
8 |
+
},
|
9 |
+
"kernelspec": {
|
10 |
+
"name": "python3",
|
11 |
+
"display_name": "Python 3"
|
12 |
+
},
|
13 |
+
"language_info": {
|
14 |
+
"name": "python"
|
15 |
+
},
|
16 |
+
"accelerator": "GPU",
|
17 |
+
"widgets": {
|
18 |
+
"application/vnd.jupyter.widget-state+json": {
|
19 |
+
"d73ad5cc5b1c45e5bac35da4b105d7d4": {
|
20 |
+
"model_module": "@jupyter-widgets/controls",
|
21 |
+
"model_name": "HBoxModel",
|
22 |
+
"model_module_version": "1.5.0",
|
23 |
+
"state": {
|
24 |
+
"_dom_classes": [],
|
25 |
+
"_model_module": "@jupyter-widgets/controls",
|
26 |
+
"_model_module_version": "1.5.0",
|
27 |
+
"_model_name": "HBoxModel",
|
28 |
+
"_view_count": null,
|
29 |
+
"_view_module": "@jupyter-widgets/controls",
|
30 |
+
"_view_module_version": "1.5.0",
|
31 |
+
"_view_name": "HBoxView",
|
32 |
+
"box_style": "",
|
33 |
+
"children": [
|
34 |
+
"IPY_MODEL_c4ce5cafe6e84a6cb8a3e9a043c67913",
|
35 |
+
"IPY_MODEL_d0e4bf336ad241958372f92c3fc6cd48",
|
36 |
+
"IPY_MODEL_4f101488783446bfa337e6d4809f9ca5"
|
37 |
+
],
|
38 |
+
"layout": "IPY_MODEL_a664851d48084d5a8bed4efb15e3eecf"
|
39 |
+
}
|
40 |
+
},
|
41 |
+
"c4ce5cafe6e84a6cb8a3e9a043c67913": {
|
42 |
+
"model_module": "@jupyter-widgets/controls",
|
43 |
+
"model_name": "HTMLModel",
|
44 |
+
"model_module_version": "1.5.0",
|
45 |
+
"state": {
|
46 |
+
"_dom_classes": [],
|
47 |
+
"_model_module": "@jupyter-widgets/controls",
|
48 |
+
"_model_module_version": "1.5.0",
|
49 |
+
"_model_name": "HTMLModel",
|
50 |
+
"_view_count": null,
|
51 |
+
"_view_module": "@jupyter-widgets/controls",
|
52 |
+
"_view_module_version": "1.5.0",
|
53 |
+
"_view_name": "HTMLView",
|
54 |
+
"description": "",
|
55 |
+
"description_tooltip": null,
|
56 |
+
"layout": "IPY_MODEL_0c8774c074194255961305239d428887",
|
57 |
+
"placeholder": "",
|
58 |
+
"style": "IPY_MODEL_2d71384e54a94332ae4c21f48fe404d1",
|
59 |
+
"value": "100%"
|
60 |
+
}
|
61 |
+
},
|
62 |
+
"d0e4bf336ad241958372f92c3fc6cd48": {
|
63 |
+
"model_module": "@jupyter-widgets/controls",
|
64 |
+
"model_name": "FloatProgressModel",
|
65 |
+
"model_module_version": "1.5.0",
|
66 |
+
"state": {
|
67 |
+
"_dom_classes": [],
|
68 |
+
"_model_module": "@jupyter-widgets/controls",
|
69 |
+
"_model_module_version": "1.5.0",
|
70 |
+
"_model_name": "FloatProgressModel",
|
71 |
+
"_view_count": null,
|
72 |
+
"_view_module": "@jupyter-widgets/controls",
|
73 |
+
"_view_module_version": "1.5.0",
|
74 |
+
"_view_name": "ProgressView",
|
75 |
+
"bar_style": "success",
|
76 |
+
"description": "",
|
77 |
+
"description_tooltip": null,
|
78 |
+
"layout": "IPY_MODEL_a30a7bd69266403aa5774d3045087447",
|
79 |
+
"max": 49,
|
80 |
+
"min": 0,
|
81 |
+
"orientation": "horizontal",
|
82 |
+
"style": "IPY_MODEL_7edfc44057194cdb8880a1544cf13d3e",
|
83 |
+
"value": 49
|
84 |
+
}
|
85 |
+
},
|
86 |
+
"4f101488783446bfa337e6d4809f9ca5": {
|
87 |
+
"model_module": "@jupyter-widgets/controls",
|
88 |
+
"model_name": "HTMLModel",
|
89 |
+
"model_module_version": "1.5.0",
|
90 |
+
"state": {
|
91 |
+
"_dom_classes": [],
|
92 |
+
"_model_module": "@jupyter-widgets/controls",
|
93 |
+
"_model_module_version": "1.5.0",
|
94 |
+
"_model_name": "HTMLModel",
|
95 |
+
"_view_count": null,
|
96 |
+
"_view_module": "@jupyter-widgets/controls",
|
97 |
+
"_view_module_version": "1.5.0",
|
98 |
+
"_view_name": "HTMLView",
|
99 |
+
"description": "",
|
100 |
+
"description_tooltip": null,
|
101 |
+
"layout": "IPY_MODEL_d332c661fc54456c9e007a6257c08427",
|
102 |
+
"placeholder": "",
|
103 |
+
"style": "IPY_MODEL_9302974855bc4f25bc4e5239e87fbfc3",
|
104 |
+
"value": " 49/49 [00:37<00:00, 1.23it/s]"
|
105 |
+
}
|
106 |
+
},
|
107 |
+
"a664851d48084d5a8bed4efb15e3eecf": {
|
108 |
+
"model_module": "@jupyter-widgets/base",
|
109 |
+
"model_name": "LayoutModel",
|
110 |
+
"model_module_version": "1.2.0",
|
111 |
+
"state": {
|
112 |
+
"_model_module": "@jupyter-widgets/base",
|
113 |
+
"_model_module_version": "1.2.0",
|
114 |
+
"_model_name": "LayoutModel",
|
115 |
+
"_view_count": null,
|
116 |
+
"_view_module": "@jupyter-widgets/base",
|
117 |
+
"_view_module_version": "1.2.0",
|
118 |
+
"_view_name": "LayoutView",
|
119 |
+
"align_content": null,
|
120 |
+
"align_items": null,
|
121 |
+
"align_self": null,
|
122 |
+
"border": null,
|
123 |
+
"bottom": null,
|
124 |
+
"display": null,
|
125 |
+
"flex": null,
|
126 |
+
"flex_flow": null,
|
127 |
+
"grid_area": null,
|
128 |
+
"grid_auto_columns": null,
|
129 |
+
"grid_auto_flow": null,
|
130 |
+
"grid_auto_rows": null,
|
131 |
+
"grid_column": null,
|
132 |
+
"grid_gap": null,
|
133 |
+
"grid_row": null,
|
134 |
+
"grid_template_areas": null,
|
135 |
+
"grid_template_columns": null,
|
136 |
+
"grid_template_rows": null,
|
137 |
+
"height": null,
|
138 |
+
"justify_content": null,
|
139 |
+
"justify_items": null,
|
140 |
+
"left": null,
|
141 |
+
"margin": null,
|
142 |
+
"max_height": null,
|
143 |
+
"max_width": null,
|
144 |
+
"min_height": null,
|
145 |
+
"min_width": null,
|
146 |
+
"object_fit": null,
|
147 |
+
"object_position": null,
|
148 |
+
"order": null,
|
149 |
+
"overflow": null,
|
150 |
+
"overflow_x": null,
|
151 |
+
"overflow_y": null,
|
152 |
+
"padding": null,
|
153 |
+
"right": null,
|
154 |
+
"top": null,
|
155 |
+
"visibility": null,
|
156 |
+
"width": null
|
157 |
+
}
|
158 |
+
},
|
159 |
+
"0c8774c074194255961305239d428887": {
|
160 |
+
"model_module": "@jupyter-widgets/base",
|
161 |
+
"model_name": "LayoutModel",
|
162 |
+
"model_module_version": "1.2.0",
|
163 |
+
"state": {
|
164 |
+
"_model_module": "@jupyter-widgets/base",
|
165 |
+
"_model_module_version": "1.2.0",
|
166 |
+
"_model_name": "LayoutModel",
|
167 |
+
"_view_count": null,
|
168 |
+
"_view_module": "@jupyter-widgets/base",
|
169 |
+
"_view_module_version": "1.2.0",
|
170 |
+
"_view_name": "LayoutView",
|
171 |
+
"align_content": null,
|
172 |
+
"align_items": null,
|
173 |
+
"align_self": null,
|
174 |
+
"border": null,
|
175 |
+
"bottom": null,
|
176 |
+
"display": null,
|
177 |
+
"flex": null,
|
178 |
+
"flex_flow": null,
|
179 |
+
"grid_area": null,
|
180 |
+
"grid_auto_columns": null,
|
181 |
+
"grid_auto_flow": null,
|
182 |
+
"grid_auto_rows": null,
|
183 |
+
"grid_column": null,
|
184 |
+
"grid_gap": null,
|
185 |
+
"grid_row": null,
|
186 |
+
"grid_template_areas": null,
|
187 |
+
"grid_template_columns": null,
|
188 |
+
"grid_template_rows": null,
|
189 |
+
"height": null,
|
190 |
+
"justify_content": null,
|
191 |
+
"justify_items": null,
|
192 |
+
"left": null,
|
193 |
+
"margin": null,
|
194 |
+
"max_height": null,
|
195 |
+
"max_width": null,
|
196 |
+
"min_height": null,
|
197 |
+
"min_width": null,
|
198 |
+
"object_fit": null,
|
199 |
+
"object_position": null,
|
200 |
+
"order": null,
|
201 |
+
"overflow": null,
|
202 |
+
"overflow_x": null,
|
203 |
+
"overflow_y": null,
|
204 |
+
"padding": null,
|
205 |
+
"right": null,
|
206 |
+
"top": null,
|
207 |
+
"visibility": null,
|
208 |
+
"width": null
|
209 |
+
}
|
210 |
+
},
|
211 |
+
"2d71384e54a94332ae4c21f48fe404d1": {
|
212 |
+
"model_module": "@jupyter-widgets/controls",
|
213 |
+
"model_name": "DescriptionStyleModel",
|
214 |
+
"model_module_version": "1.5.0",
|
215 |
+
"state": {
|
216 |
+
"_model_module": "@jupyter-widgets/controls",
|
217 |
+
"_model_module_version": "1.5.0",
|
218 |
+
"_model_name": "DescriptionStyleModel",
|
219 |
+
"_view_count": null,
|
220 |
+
"_view_module": "@jupyter-widgets/base",
|
221 |
+
"_view_module_version": "1.2.0",
|
222 |
+
"_view_name": "StyleView",
|
223 |
+
"description_width": ""
|
224 |
+
}
|
225 |
+
},
|
226 |
+
"a30a7bd69266403aa5774d3045087447": {
|
227 |
+
"model_module": "@jupyter-widgets/base",
|
228 |
+
"model_name": "LayoutModel",
|
229 |
+
"model_module_version": "1.2.0",
|
230 |
+
"state": {
|
231 |
+
"_model_module": "@jupyter-widgets/base",
|
232 |
+
"_model_module_version": "1.2.0",
|
233 |
+
"_model_name": "LayoutModel",
|
234 |
+
"_view_count": null,
|
235 |
+
"_view_module": "@jupyter-widgets/base",
|
236 |
+
"_view_module_version": "1.2.0",
|
237 |
+
"_view_name": "LayoutView",
|
238 |
+
"align_content": null,
|
239 |
+
"align_items": null,
|
240 |
+
"align_self": null,
|
241 |
+
"border": null,
|
242 |
+
"bottom": null,
|
243 |
+
"display": null,
|
244 |
+
"flex": null,
|
245 |
+
"flex_flow": null,
|
246 |
+
"grid_area": null,
|
247 |
+
"grid_auto_columns": null,
|
248 |
+
"grid_auto_flow": null,
|
249 |
+
"grid_auto_rows": null,
|
250 |
+
"grid_column": null,
|
251 |
+
"grid_gap": null,
|
252 |
+
"grid_row": null,
|
253 |
+
"grid_template_areas": null,
|
254 |
+
"grid_template_columns": null,
|
255 |
+
"grid_template_rows": null,
|
256 |
+
"height": null,
|
257 |
+
"justify_content": null,
|
258 |
+
"justify_items": null,
|
259 |
+
"left": null,
|
260 |
+
"margin": null,
|
261 |
+
"max_height": null,
|
262 |
+
"max_width": null,
|
263 |
+
"min_height": null,
|
264 |
+
"min_width": null,
|
265 |
+
"object_fit": null,
|
266 |
+
"object_position": null,
|
267 |
+
"order": null,
|
268 |
+
"overflow": null,
|
269 |
+
"overflow_x": null,
|
270 |
+
"overflow_y": null,
|
271 |
+
"padding": null,
|
272 |
+
"right": null,
|
273 |
+
"top": null,
|
274 |
+
"visibility": null,
|
275 |
+
"width": null
|
276 |
+
}
|
277 |
+
},
|
278 |
+
"7edfc44057194cdb8880a1544cf13d3e": {
|
279 |
+
"model_module": "@jupyter-widgets/controls",
|
280 |
+
"model_name": "ProgressStyleModel",
|
281 |
+
"model_module_version": "1.5.0",
|
282 |
+
"state": {
|
283 |
+
"_model_module": "@jupyter-widgets/controls",
|
284 |
+
"_model_module_version": "1.5.0",
|
285 |
+
"_model_name": "ProgressStyleModel",
|
286 |
+
"_view_count": null,
|
287 |
+
"_view_module": "@jupyter-widgets/base",
|
288 |
+
"_view_module_version": "1.2.0",
|
289 |
+
"_view_name": "StyleView",
|
290 |
+
"bar_color": null,
|
291 |
+
"description_width": ""
|
292 |
+
}
|
293 |
+
},
|
294 |
+
"d332c661fc54456c9e007a6257c08427": {
|
295 |
+
"model_module": "@jupyter-widgets/base",
|
296 |
+
"model_name": "LayoutModel",
|
297 |
+
"model_module_version": "1.2.0",
|
298 |
+
"state": {
|
299 |
+
"_model_module": "@jupyter-widgets/base",
|
300 |
+
"_model_module_version": "1.2.0",
|
301 |
+
"_model_name": "LayoutModel",
|
302 |
+
"_view_count": null,
|
303 |
+
"_view_module": "@jupyter-widgets/base",
|
304 |
+
"_view_module_version": "1.2.0",
|
305 |
+
"_view_name": "LayoutView",
|
306 |
+
"align_content": null,
|
307 |
+
"align_items": null,
|
308 |
+
"align_self": null,
|
309 |
+
"border": null,
|
310 |
+
"bottom": null,
|
311 |
+
"display": null,
|
312 |
+
"flex": null,
|
313 |
+
"flex_flow": null,
|
314 |
+
"grid_area": null,
|
315 |
+
"grid_auto_columns": null,
|
316 |
+
"grid_auto_flow": null,
|
317 |
+
"grid_auto_rows": null,
|
318 |
+
"grid_column": null,
|
319 |
+
"grid_gap": null,
|
320 |
+
"grid_row": null,
|
321 |
+
"grid_template_areas": null,
|
322 |
+
"grid_template_columns": null,
|
323 |
+
"grid_template_rows": null,
|
324 |
+
"height": null,
|
325 |
+
"justify_content": null,
|
326 |
+
"justify_items": null,
|
327 |
+
"left": null,
|
328 |
+
"margin": null,
|
329 |
+
"max_height": null,
|
330 |
+
"max_width": null,
|
331 |
+
"min_height": null,
|
332 |
+
"min_width": null,
|
333 |
+
"object_fit": null,
|
334 |
+
"object_position": null,
|
335 |
+
"order": null,
|
336 |
+
"overflow": null,
|
337 |
+
"overflow_x": null,
|
338 |
+
"overflow_y": null,
|
339 |
+
"padding": null,
|
340 |
+
"right": null,
|
341 |
+
"top": null,
|
342 |
+
"visibility": null,
|
343 |
+
"width": null
|
344 |
+
}
|
345 |
+
},
|
346 |
+
"9302974855bc4f25bc4e5239e87fbfc3": {
|
347 |
+
"model_module": "@jupyter-widgets/controls",
|
348 |
+
"model_name": "DescriptionStyleModel",
|
349 |
+
"model_module_version": "1.5.0",
|
350 |
+
"state": {
|
351 |
+
"_model_module": "@jupyter-widgets/controls",
|
352 |
+
"_model_module_version": "1.5.0",
|
353 |
+
"_model_name": "DescriptionStyleModel",
|
354 |
+
"_view_count": null,
|
355 |
+
"_view_module": "@jupyter-widgets/base",
|
356 |
+
"_view_module_version": "1.2.0",
|
357 |
+
"_view_name": "StyleView",
|
358 |
+
"description_width": ""
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
},
|
364 |
+
"cells": [
|
365 |
+
{
|
366 |
+
"cell_type": "code",
|
367 |
+
"source": [
|
368 |
+
"!pip install gradio"
|
369 |
+
],
|
370 |
+
"metadata": {
|
371 |
+
"id": "sFIrvgM6Zz9i"
|
372 |
+
},
|
373 |
+
"execution_count": null,
|
374 |
+
"outputs": []
|
375 |
+
},
|
376 |
+
{
|
377 |
+
"cell_type": "code",
|
378 |
+
"execution_count": null,
|
379 |
+
"metadata": {
|
380 |
+
"id": "k5XlAek1Zwpz"
|
381 |
+
},
|
382 |
+
"outputs": [],
|
383 |
+
"source": [
|
384 |
+
"import torch\n",
|
385 |
+
"from diffusers import AutoPipelineForInpainting\n",
|
386 |
+
"from PIL import Image\n",
|
387 |
+
"\n",
|
388 |
+
"# Check for GPU availability\n",
|
389 |
+
"device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
|
390 |
+
"\n",
|
391 |
+
"# Load the inpainting pipeline\n",
|
392 |
+
"pipe = AutoPipelineForInpainting.from_pretrained(\n",
|
393 |
+
" \"diffusers/stable-diffusion-xl-1.0-inpainting-0.1\",\n",
|
394 |
+
" torch_dtype=torch.float16, # Use float16 for efficiency\n",
|
395 |
+
" variant=\"fp16\"\n",
|
396 |
+
").to(device)\n"
|
397 |
+
]
|
398 |
+
},
|
399 |
+
{
|
400 |
+
"cell_type": "code",
|
401 |
+
"source": [
|
402 |
+
"# Load input images\n",
|
403 |
+
"background_image = Image.open(\"woman.png\").convert(\"RGB\") # Ensure RGB format\n",
|
404 |
+
"mask_image = Image.open(\"mask.png\").convert(\"L\") # Ensure grayscale format\n",
|
405 |
+
"# Resize the mask to match the background image size\n",
|
406 |
+
"mask_image = mask_image.resize(background_image.size, Image.LANCZOS)"
|
407 |
+
],
|
408 |
+
"metadata": {
|
409 |
+
"id": "JDCRPTsFM3B7"
|
410 |
+
},
|
411 |
+
"execution_count": 6,
|
412 |
+
"outputs": []
|
413 |
+
},
|
414 |
+
{
|
415 |
+
"cell_type": "code",
|
416 |
+
"source": [
|
417 |
+
"output = pipe(\n",
|
418 |
+
" prompt=\"A Woman wearing sunglasses, smiling\",\n",
|
419 |
+
" negative_prompt=\"ugly, low quality, blur, distorted, unreal\",\n",
|
420 |
+
" image=background_image,\n",
|
421 |
+
" mask_image=mask_image,\n",
|
422 |
+
" guidance_scale=7.5,\n",
|
423 |
+
" num_inference_steps=50,\n",
|
424 |
+
" strength=0.99,\n",
|
425 |
+
" height=background_image.size[1],\n",
|
426 |
+
" width=background_image.size[0]\n",
|
427 |
+
")\n",
|
428 |
+
"\n",
|
429 |
+
"\n",
|
430 |
+
"# Save and display output\n",
|
431 |
+
"inpainted_image = output.images[0]\n",
|
432 |
+
"inpainted_image.save(\"output.png\")\n",
|
433 |
+
"inpainted_image.show()\n"
|
434 |
+
],
|
435 |
+
"metadata": {
|
436 |
+
"colab": {
|
437 |
+
"base_uri": "https://localhost:8080/",
|
438 |
+
"height": 49,
|
439 |
+
"referenced_widgets": [
|
440 |
+
"d73ad5cc5b1c45e5bac35da4b105d7d4",
|
441 |
+
"c4ce5cafe6e84a6cb8a3e9a043c67913",
|
442 |
+
"d0e4bf336ad241958372f92c3fc6cd48",
|
443 |
+
"4f101488783446bfa337e6d4809f9ca5",
|
444 |
+
"a664851d48084d5a8bed4efb15e3eecf",
|
445 |
+
"0c8774c074194255961305239d428887",
|
446 |
+
"2d71384e54a94332ae4c21f48fe404d1",
|
447 |
+
"a30a7bd69266403aa5774d3045087447",
|
448 |
+
"7edfc44057194cdb8880a1544cf13d3e",
|
449 |
+
"d332c661fc54456c9e007a6257c08427",
|
450 |
+
"9302974855bc4f25bc4e5239e87fbfc3"
|
451 |
+
]
|
452 |
+
},
|
453 |
+
"id": "u4KLSfGPNAZK",
|
454 |
+
"outputId": "f63805bc-5315-4541-8633-e3ddcc9bc4fd"
|
455 |
+
},
|
456 |
+
"execution_count": 10,
|
457 |
+
"outputs": [
|
458 |
+
{
|
459 |
+
"output_type": "display_data",
|
460 |
+
"data": {
|
461 |
+
"text/plain": [
|
462 |
+
" 0%| | 0/49 [00:00<?, ?it/s]"
|
463 |
+
],
|
464 |
+
"application/vnd.jupyter.widget-view+json": {
|
465 |
+
"version_major": 2,
|
466 |
+
"version_minor": 0,
|
467 |
+
"model_id": "d73ad5cc5b1c45e5bac35da4b105d7d4"
|
468 |
+
}
|
469 |
+
},
|
470 |
+
"metadata": {}
|
471 |
+
}
|
472 |
+
]
|
473 |
+
}
|
474 |
+
]
|
475 |
+
}
|
app.py
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
import torch
|
4 |
+
import logging
|
5 |
+
import os
|
6 |
+
import cv2
|
7 |
+
from huggingface_hub import login
|
8 |
+
from diffusers import AutoPipelineForInpainting, UNet2DConditionModel
|
9 |
+
import diffusers
|
10 |
+
import spaces # type: ignore
|
11 |
+
from PIL import Image
|
12 |
+
|
13 |
+
login(os.getenv("HF_TOKEN"))
|
14 |
+
|
15 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
+
|
17 |
+
pipe = AutoPipelineForInpainting.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", torch_dtype=torch.float16, variant="fp16").to(device, dtype=torch.float16)
|
18 |
+
|
19 |
+
# Configure logging
|
20 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
21 |
+
|
22 |
+
@spaces.GPU()
|
23 |
+
def predict(image, mask=None, positive_prompt="", negative_prompt=None, guidance_scale=7.5, steps=20, strength=1.0, scheduler="EulerDiscreteScheduler"):
|
24 |
+
try:
|
25 |
+
logging.info("Starting inpainting process")
|
26 |
+
|
27 |
+
scheduler_parts = scheduler.split("-")
|
28 |
+
scheduler_class_name = scheduler_parts[0]
|
29 |
+
add_kwargs = {}
|
30 |
+
|
31 |
+
if len(scheduler_parts) > 1:
|
32 |
+
add_kwargs["use_karras"] = True
|
33 |
+
if len(scheduler_parts) > 2:
|
34 |
+
add_kwargs["algorithm_type"] = "sde-dpmsolver++"
|
35 |
+
|
36 |
+
logging.info(f"Using scheduler: {scheduler_class_name} with args {add_kwargs}")
|
37 |
+
|
38 |
+
scheduler_cls = getattr(diffusers, scheduler_class_name)
|
39 |
+
|
40 |
+
source_image = Image.fromarray(image["background"]).convert("RGB")
|
41 |
+
|
42 |
+
if np.unique(mask["background"]).size == 1:
|
43 |
+
alpha_channel = image["layers"][0][:, :, 3]
|
44 |
+
mask = np.where(alpha_channel == 255,255,0).astype(np.uint8)
|
45 |
+
mask_4ch = np.stack([mask] * 4, axis=2)
|
46 |
+
mask_image = Image.fromarray(mask_4ch)
|
47 |
+
logging.info(f"Mask was not uploaded")
|
48 |
+
else :
|
49 |
+
mask_image = Image.fromarray(mask["background"]).convert("RGBA")
|
50 |
+
print(type(mask["background"]))
|
51 |
+
print("Value of Mask : ", mask)
|
52 |
+
print("Value of Mask : ", mask["background"])
|
53 |
+
logging.info(f"Mask was uploaded")
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
logging.info("Converted images to required formats")
|
58 |
+
|
59 |
+
# Set the scheduler
|
60 |
+
pipe.scheduler = scheduler_cls.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler", **add_kwargs)
|
61 |
+
logging.info("Scheduler set successfully")
|
62 |
+
|
63 |
+
h = (source_image.height//8) * 8
|
64 |
+
w = (source_image.width//8) * 8
|
65 |
+
# Run the inpainting model
|
66 |
+
output = pipe(
|
67 |
+
prompt=positive_prompt,
|
68 |
+
negative_prompt=negative_prompt,
|
69 |
+
image=source_image,
|
70 |
+
height=h,
|
71 |
+
width=w,
|
72 |
+
mask_image=mask_image,
|
73 |
+
guidance_scale=guidance_scale,
|
74 |
+
num_inference_steps=int(steps),
|
75 |
+
strength=strength
|
76 |
+
)
|
77 |
+
logging.info("Model inference completed successfully")
|
78 |
+
|
79 |
+
|
80 |
+
return output.images[0], mask_image
|
81 |
+
|
82 |
+
except Exception as e:
|
83 |
+
logging.error(f"Error occurred: {str(e)}", exc_info=True)
|
84 |
+
return None
|
85 |
+
|
86 |
+
|
87 |
+
with gr.Blocks() as demo:
|
88 |
+
with gr.Row():
|
89 |
+
with gr.Column():
|
90 |
+
image = gr.ImageMask(
|
91 |
+
type="numpy", label="Input Image", layers=False
|
92 |
+
)
|
93 |
+
with gr.Row():
|
94 |
+
positive_prompt = gr.Textbox(placeholder="Your prompt", label="Positive Prompt")
|
95 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What you don't want to see in the image")
|
96 |
+
with gr.Row():
|
97 |
+
btn = gr.Button("Inpaint")
|
98 |
+
with gr.Accordion(label="Advanced Settings", open=False):
|
99 |
+
with gr.Row():
|
100 |
+
guidance_scale = gr.Number(value=7.5, minimum=1.0, maximum=20.0, step=0.1, label="Guidance Scale")
|
101 |
+
steps = gr.Number(value=50, minimum=10, maximum=100, step=1, label="Steps")
|
102 |
+
strength = gr.Number(value=0.80, minimum=0.01, maximum=1.0, step=0.01, label="Strength")
|
103 |
+
|
104 |
+
with gr.Row():
|
105 |
+
schedulers = ["DEISMultistepScheduler", "HeunDiscreteScheduler", "EulerDiscreteScheduler", "DPMSolverMultistepScheduler", "DPMSolverMultistepScheduler-Karras", "DPMSolverMultistepScheduler-Karras-SDE"]
|
106 |
+
scheduler = gr.Dropdown(label="Schedulers", choices=schedulers, value="DPMSolverMultistepScheduler-Karras-SDE")
|
107 |
+
with gr.Row():
|
108 |
+
mask = gr.ImageMask(label="Mask", format="png", value=None, sources=["upload"])
|
109 |
+
mask_image = gr.Image(label="Mask Image", format="png")
|
110 |
+
with gr.Column():
|
111 |
+
image_out = gr.Image(label="Output", format="png")
|
112 |
+
|
113 |
+
btn.click(fn=predict, inputs=[image, mask, positive_prompt, negative_prompt, guidance_scale, steps, strength, scheduler], outputs=[image_out, mask_image])
|
114 |
+
|
115 |
+
demo.launch(debug=True,show_error=True)
|
requirements.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
--extra-index-url https://download.pytorch.org/whl/cu118
|
2 |
+
torch
|
3 |
+
git+https://github.com/huggingface/diffusers.git
|
4 |
+
transformers
|
5 |
+
accelerate
|
6 |
+
ftfy
|
7 |
+
numpy
|
8 |
+
matplotlib
|
9 |
+
uuid
|
10 |
+
opencv-python
|