nightfury commited on
Commit
a3f2113
1 Parent(s): d4a60e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +86 -5
app.py CHANGED
@@ -45,7 +45,7 @@ api.upload_folder(
45
  #.commit(commit_message="clipseg uploaded...")
46
  # with open("file.txt", "w+") as f:
47
  # f.write(json.dumps({"hey": 8}))
48
-
49
 
50
  auth_token = os.environ.get("API_TOKEN") or True
51
 
@@ -149,11 +149,11 @@ with image_blocks as demo:
149
  fill="none"
150
  xmlns="http://www.w3.org/2000/svg"
151
  >
152
- <rect width="23" height="23" fill="white"></rect>
153
- <rect y="69" width="23" height="23" fill="white"></rect>
154
  <rect x="23" width="23" height="23" fill="#AEAEAE"></rect>
155
  <rect x="23" y="69" width="23" height="23" fill="#AEAEAE"></rect>
156
- <rect x="46" width="23" height="23" fill="white"></rect>
157
  <rect x="46" y="69" width="23" height="23" fill="white"></rect>
158
  <rect x="69" width="23" height="23" fill="black"></rect>
159
  <rect x="69" y="69" width="23" height="23" fill="black"></rect>
@@ -180,7 +180,7 @@ with image_blocks as demo:
180
  </h1>
181
  </div>
182
  <p style="margin-bottom: 10px; font-size: 94%">
183
- Inpaint Stable Diffusion by either drawing a mask or typing what to replace
184
  </p>
185
  </div>
186
  """
@@ -205,6 +205,87 @@ with image_blocks as demo:
205
  btn.click(fn=predict, inputs=[radio, image, word_mask, prompt], outputs=result)
206
  gr.HTML(
207
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  <div class="footer">
209
  <p>Model by <a href="https://huggingface.co/CompVis" style="text-decoration: underline;" target="_blank">CompVis</a> and <a href="https://huggingface.co/stabilityai" style="text-decoration: underline;" target="_blank">Stability AI</a> - Inpainting by <a href="https://github.com/" style="text-decoration: underline;" target="_blank">NightFury</a> using clipseg[model] with bit modification - Gradio Demo on 🤗 Hugging Face
210
  </p>
 
45
  #.commit(commit_message="clipseg uploaded...")
46
  # with open("file.txt", "w+") as f:
47
  # f.write(json.dumps({"hey": 8}))
48
+
49
 
50
  auth_token = os.environ.get("API_TOKEN") or True
51
 
 
149
  fill="none"
150
  xmlns="http://www.w3.org/2000/svg"
151
  >
152
+ <rect width="23" height="23" fill="#AEAEAE"></rect>
153
+ <rect y="69" width="23" height="23" fill="black"></rect>
154
  <rect x="23" width="23" height="23" fill="#AEAEAE"></rect>
155
  <rect x="23" y="69" width="23" height="23" fill="#AEAEAE"></rect>
156
+ <rect x="46" width="23" height="23" fill="#D9D9D9"></rect>
157
  <rect x="46" y="69" width="23" height="23" fill="white"></rect>
158
  <rect x="69" width="23" height="23" fill="black"></rect>
159
  <rect x="69" y="69" width="23" height="23" fill="black"></rect>
 
180
  </h1>
181
  </div>
182
  <p style="margin-bottom: 10px; font-size: 94%">
183
+ Inpaint Stable Diffusion by either drawing a mask or typing what to replace & what to keep !!!
184
  </p>
185
  </div>
186
  """
 
205
  btn.click(fn=predict, inputs=[radio, image, word_mask, prompt], outputs=result)
206
  gr.HTML(
207
  """
208
+ # Image Segmentation Using Text and Image Prompts
209
+ This repository contains the code used in the paper ["Image Segmentation Using Text and Image Prompts"](https://arxiv.org/abs/2112.10003).
210
+
211
+ **The Paper has been accepted to CVPR 2022!**
212
+
213
+ <img src="overview.png" alt="drawing" height="200em"/>
214
+
215
+ The systems allows to create segmentation models without training based on:
216
+ - An arbitrary text query
217
+ - Or an image with a mask highlighting stuff or an object.
218
+
219
+ ### Quick Start
220
+
221
+ In the `Quickstart.ipynb` notebook we provide the code for using a pre-trained CLIPSeg model. If you run the notebook locally, make sure you downloaded the `rd64-uni.pth` weights, either manually or via git lfs extension.
222
+ It can also be used interactively using [MyBinder](https://mybinder.org/v2/gh/timojl/clipseg/HEAD?labpath=Quickstart.ipynb)
223
+ (please note that the VM does not use a GPU, thus inference takes a few seconds).
224
+
225
+
226
+ ### Dependencies
227
+ This code base depends on pytorch, torchvision and clip (`pip install git+https://github.com/openai/CLIP.git`).
228
+ Additional dependencies are hidden for double blind review.
229
+
230
+
231
+ ### Datasets
232
+
233
+ * `PhraseCut` and `PhraseCutPlus`: Referring expression dataset
234
+ * `PFEPascalWrapper`: Wrapper class for PFENet's Pascal-5i implementation
235
+ * `PascalZeroShot`: Wrapper class for PascalZeroShot
236
+ * `COCOWrapper`: Wrapper class for COCO.
237
+
238
+ ### Models
239
+
240
+ * `CLIPDensePredT`: CLIPSeg model with transformer-based decoder.
241
+ * `ViTDensePredT`: CLIPSeg model with transformer-based decoder.
242
+
243
+ ### Third Party Dependencies
244
+ For some of the datasets third party dependencies are required. Run the following commands in the `third_party` folder.
245
+ ```bash
246
+ git clone https://github.com/cvlab-yonsei/JoEm
247
+ git clone https://github.com/Jia-Research-Lab/PFENet.git
248
+ git clone https://github.com/ChenyunWu/PhraseCutDataset.git
249
+ git clone https://github.com/juhongm999/hsnet.git
250
+ ```
251
+
252
+ ### Weights
253
+
254
+ The MIT license does not apply to these weights.
255
+
256
+ - [CLIPSeg-D64](https://github.com/timojl/clipseg/raw/master/weights/rd64-uni.pth) (4.1MB, without CLIP weights)
257
+ - [CLIPSeg-D16](https://github.com/timojl/clipseg/raw/master/weights/rd16-uni.pth) (1.1MB, without CLIP weights)
258
+
259
+ ### Training and Evaluation
260
+
261
+ To train use the `training.py` script with experiment file and experiment id parameters. E.g. `python training.py phrasecut.yaml 0` will train the first phrasecut experiment which is defined by the `configuration` and first `individual_configurations` parameters. Model weights will be written in `logs/`.
262
+
263
+ For evaluation use `score.py`. E.g. `python score.py phrasecut.yaml 0 0` will train the first phrasecut experiment of `test_configuration` and the first configuration in `individual_configurations`.
264
+
265
+
266
+ ### Usage of PFENet Wrappers
267
+
268
+ In order to use the dataset and model wrappers for PFENet, the PFENet repository needs to be cloned to the root folder.
269
+ `git clone https://github.com/Jia-Research-Lab/PFENet.git `
270
+
271
+
272
+ ### License
273
+
274
+ The source code files in this repository (excluding model weights) are released under MIT license.
275
+
276
+ ### Citation
277
+ ```
278
+ @InProceedings{lueddecke22_cvpr,
279
+ author = {L\"uddecke, Timo and Ecker, Alexander},
280
+ title = {Image Segmentation Using Text and Image Prompts},
281
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
282
+ month = {June},
283
+ year = {2022},
284
+ pages = {7086-7096}
285
+ }
286
+
287
+ ```
288
+
289
  <div class="footer">
290
  <p>Model by <a href="https://huggingface.co/CompVis" style="text-decoration: underline;" target="_blank">CompVis</a> and <a href="https://huggingface.co/stabilityai" style="text-decoration: underline;" target="_blank">Stability AI</a> - Inpainting by <a href="https://github.com/" style="text-decoration: underline;" target="_blank">NightFury</a> using clipseg[model] with bit modification - Gradio Demo on 🤗 Hugging Face
291
  </p>