nightfury commited on
Commit
3ad2222
1 Parent(s): a3f2113

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -82
app.py CHANGED
@@ -205,91 +205,77 @@ with image_blocks as demo:
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>
292
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  <div class="acknowledgments">
294
  <p><h4>LICENSE</h4>
295
  The model is licensed with a <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" style="text-decoration: underline;" target="_blank">CreativeML Open RAIL-M</a> license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" target="_blank" style="text-decoration: underline;" target="_blank">read the license</a></p>
 
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>
211
  </div>
212
+
213
+
214
+ <div id="readme" class="Box-body readme blob js-code-block-container p-5 p-xl-6 gist-border-0">
215
+ <article class="markdown-body entry-content container-lg" itemprop="text"><h1 dir="auto"><a id="user-content-image-segmentation-using-text-and-image-prompts" class="anchor" aria-hidden="true" href="#image-segmentation-using-text-and-image-prompts"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Image Segmentation Using Text and Image Prompts</h1>
216
+ <p dir="auto">This repository contains the code used in the paper <a href="https://arxiv.org/abs/2112.10003" rel="nofollow">"Image Segmentation Using Text and Image Prompts"</a>.</p>
217
+ <p dir="auto"><strong>The Paper has been accepted to CVPR 2022!</strong></p>
218
+ <p dir="auto"><a target="_blank" rel="noopener noreferrer" href="/ThereforeGames/txt2mask/blob/main/repositories/clipseg/overview.png"><img src="/ThereforeGames/txt2mask/raw/main/repositories/clipseg/overview.png" alt="drawing" style="max-width: 100%;" height="200em"></a></p>
219
+ <p dir="auto">The systems allows to create segmentation models without training based on:</p>
220
+ <ul dir="auto">
221
+ <li>An arbitrary text query</li>
222
+ <li>Or an image with a mask highlighting stuff or an object.</li>
223
+ </ul>
224
+ <h3 dir="auto"><a id="user-content-quick-start" class="anchor" aria-hidden="true" href="#quick-start"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Quick Start</h3>
225
+ <p dir="auto">In the <code>Quickstart.ipynb</code> notebook we provide the code for using a pre-trained CLIPSeg model. If you run the notebook locally, make sure you downloaded the <code>rd64-uni.pth</code> weights, either manually or via git lfs extension.
226
+ It can also be used interactively using <a href="https://mybinder.org/v2/gh/timojl/clipseg/HEAD?labpath=Quickstart.ipynb" rel="nofollow">MyBinder</a>
227
+ (please note that the VM does not use a GPU, thus inference takes a few seconds).</p>
228
+ <h3 dir="auto"><a id="user-content-dependencies" class="anchor" aria-hidden="true" href="#dependencies"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Dependencies</h3>
229
+ <p dir="auto">This code base depends on pytorch, torchvision and clip (<code>pip install git+https://github.com/openai/CLIP.git</code>).
230
+ Additional dependencies are hidden for double blind review.</p>
231
+ <h3 dir="auto"><a id="user-content-datasets" class="anchor" aria-hidden="true" href="#datasets"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Datasets</h3>
232
+ <ul dir="auto">
233
+ <li><code>PhraseCut</code> and <code>PhraseCutPlus</code>: Referring expression dataset</li>
234
+ <li><code>PFEPascalWrapper</code>: Wrapper class for PFENet's Pascal-5i implementation</li>
235
+ <li><code>PascalZeroShot</code>: Wrapper class for PascalZeroShot</li>
236
+ <li><code>COCOWrapper</code>: Wrapper class for COCO.</li>
237
+ </ul>
238
+ <h3 dir="auto"><a id="user-content-models" class="anchor" aria-hidden="true" href="#models"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Models</h3>
239
+ <ul dir="auto">
240
+ <li><code>CLIPDensePredT</code>: CLIPSeg model with transformer-based decoder.</li>
241
+ <li><code>ViTDensePredT</code>: CLIPSeg model with transformer-based decoder.</li>
242
+ </ul>
243
+ <h3 dir="auto"><a id="user-content-third-party-dependencies" class="anchor" aria-hidden="true" href="#third-party-dependencies"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Third Party Dependencies</h3>
244
+ <p dir="auto">For some of the datasets third party dependencies are required. Run the following commands in the <code>third_party</code> folder.</p>
245
+ <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto"><pre>git clone https://github.com/cvlab-yonsei/JoEm
246
+ git clone https://github.com/Jia-Research-Lab/PFENet.git
247
+ git clone https://github.com/ChenyunWu/PhraseCutDataset.git
248
+ git clone https://github.com/juhongm999/hsnet.git</pre><div class="zeroclipboard-container position-absolute right-0 top-0">
249
+ <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w" value="git clone https://github.com/cvlab-yonsei/JoEm
250
+ git clone https://github.com/Jia-Research-Lab/PFENet.git
251
+ git clone https://github.com/ChenyunWu/PhraseCutDataset.git
252
+ git clone https://github.com/juhongm999/hsnet.git" tabindex="0" role="button">
253
+ <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2">
254
+ <path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path>
255
+ </svg>
256
+ <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2">
257
+ <path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path>
258
+ </svg>
259
+ </clipboard-copy>
260
+ </div></div>
261
+ <h3 dir="auto"><a id="user-content-weights" class="anchor" aria-hidden="true" href="#weights"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Weights</h3>
262
+ <p dir="auto">The MIT license does not apply to these weights.</p>
263
+ <ul dir="auto">
264
+ <li><a href="https://github.com/timojl/clipseg/raw/master/weights/rd64-uni.pth">CLIPSeg-D64</a> (4.1MB, without CLIP weights)</li>
265
+ <li><a href="https://github.com/timojl/clipseg/raw/master/weights/rd16-uni.pth">CLIPSeg-D16</a> (1.1MB, without CLIP weights)</li>
266
+ </ul>
267
+ <h3 dir="auto"><a id="user-content-training-and-evaluation" class="anchor" aria-hidden="true" href="#training-and-evaluation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Training and Evaluation</h3>
268
+ <p dir="auto">To train use the <code>training.py</code> script with experiment file and experiment id parameters. E.g. <code>python training.py phrasecut.yaml 0</code> will train the first phrasecut experiment which is defined by the <code>configuration</code> and first <code>individual_configurations</code> parameters. Model weights will be written in <code>logs/</code>.</p>
269
+ <p dir="auto">For evaluation use <code>score.py</code>. E.g. <code>python score.py phrasecut.yaml 0 0</code> will train the first phrasecut experiment of <code>test_configuration</code> and the first configuration in <code>individual_configurations</code>.</p>
270
+ <h3 dir="auto"><a id="user-content-usage-of-pfenet-wrappers" class="anchor" aria-hidden="true" href="#usage-of-pfenet-wrappers"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Usage of PFENet Wrappers</h3>
271
+ <p dir="auto">In order to use the dataset and model wrappers for PFENet, the PFENet repository needs to be cloned to the root folder.
272
+ <code>git clone https://github.com/Jia-Research-Lab/PFENet.git </code></p>
273
+ <h3 dir="auto"><a id="user-content-license" class="anchor" aria-hidden="true" href="#license"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>License</h3>
274
+ <p dir="auto">The source code files in this repository (excluding model weights) are released under MIT license.</p>
275
+
276
+
277
+ </article>
278
+ </div>
279
  <div class="acknowledgments">
280
  <p><h4>LICENSE</h4>
281
  The model is licensed with a <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" style="text-decoration: underline;" target="_blank">CreativeML Open RAIL-M</a> license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" target="_blank" style="text-decoration: underline;" target="_blank">read the license</a></p>