Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,108 @@ def interface(image, model: str = "eccv16"):
|
|
20 |
)
|
21 |
return output_img
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
interface,
|
25 |
[
|
26 |
gr.components.Image(type="pil", label="image"),
|
@@ -32,5 +133,20 @@ gr.Interface(
|
|
32 |
],
|
33 |
[
|
34 |
gr.components.Image(label="output")
|
35 |
-
]
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
)
|
21 |
return output_img
|
22 |
|
23 |
+
title = "Image Colorization Using AI Models"
|
24 |
+
description = r"""An automatic colorization functionality for Real-Time User-Guided Image Colorization with Learned Deep Priors,ECCV16 & SIGGRAPH 2017 Models!<br>
|
25 |
+
Practically the algorithm is used to COLORIZE your **old BLACK & WHITE / GRAYSCALE photos**.<br>
|
26 |
+
To use it, simply just upload the concerned image.<br>
|
27 |
+
"""
|
28 |
+
article = r"""
|
29 |
+
<p style='text-align: '>
|
30 |
+
Given a grayscale photograph as input, this demo attacks the problem of hallucinating a plausible color version of the photograph. This problem is clearly underconstrained, so previous approaches have either relied on significant user interaction or resulted in desaturated colorizations. A fully automatic approach has been proposed that produces vibrant and realistic colorizations. The underlying uncertainty of the problem was embraced by posing it as a classification task and use class-rebalancing at training time to increase the diversity of colors in the result. The system is implemented as a feed-forward pass in a CNN at test time and is trained on over a million color images. The algorithm is evaluated using a "colorization Turing test," asking human participants to choose between a generated and ground truth color image. The method used here successfully fools humans on 32% of the trials, significantly higher than other methodology used by the other photo automation tools. Moreover, the colorization can be a powerful pretext task for self-supervised feature learning, acting as a cross-channel encoder. This approach results in state-of-the-art performance on several feature learning benchmarks.
|
31 |
+
</p>
|
32 |
+
<img src="https://camo.githubusercontent.com/8f849fd53753e61659664d37849703d949209ec93957d1a2fd529be9772f7030/687474703a2f2f726963687a68616e672e6769746875622e696f2f636f6c6f72697a6174696f6e2f7265736f75726365732f696d616765732f746561736572342e6a7067" alt="Teaser Image" data-canonical-src="http://richzhang.github.io/colorization/resources/images/teaser4.jpg" style="max-width: 100%;">
|
33 |
+
<p>
|
34 |
+
<img class="round" style="height:275px" src="./resources/images/net_diagram.jpg">
|
35 |
+
</p>
|
36 |
+
|
37 |
+
<div class="footer">
|
38 |
+
<p>Built by <a href="https://twitter.com/jadejadushyant" style="text-decoration: underline;" target="_blank">Dushyantsinh Jadeja</a> & the Model being used in here is from <a href="https://github.com/richzhang/colorization" style="text-decoration: underline;" target="_blank">richzhang</a> - Gradio Demo by π€ Hugging Face
|
39 |
+
</p>
|
40 |
+
</div>
|
41 |
+
<div class="acknowledgments">
|
42 |
+
<p><h4>LICENSE</h4>
|
43 |
+
<div class="d-flex flex-column flex-md-row">
|
44 |
+
<div class="p-3 col-md-6">
|
45 |
+
<svg height="32" aria-hidden="true" viewBox="0 0 24 24" version="1.1" width="32" data-view-component="true" class="octicon octicon-law color-fg-default float-left mr-2">
|
46 |
+
<path fill-rule="evenodd" d="M12.75 2.75a.75.75 0 00-1.5 0V4.5H9.276a1.75 1.75 0 00-.985.303L6.596 5.957A.25.25 0 016.455 6H2.353a.75.75 0 100 1.5H3.93L.563 15.18a.762.762 0 00.21.88c.08.064.161.125.309.221.186.121.452.278.792.433.68.311 1.662.62 2.876.62a6.919 6.919 0 002.876-.62c.34-.155.606-.312.792-.433.15-.097.23-.158.31-.223a.75.75 0 00.209-.878L5.569 7.5h.886c.351 0 .694-.106.984-.303l1.696-1.154A.25.25 0 019.275 6h1.975v14.5H6.763a.75.75 0 000 1.5h10.474a.75.75 0 000-1.5H12.75V6h1.974c.05 0 .1.015.14.043l1.697 1.154c.29.197.633.303.984.303h.886l-3.368 7.68a.75.75 0 00.23.896c.012.009 0 0 .002 0a3.154 3.154 0 00.31.206c.185.112.45.256.79.4a7.343 7.343 0 002.855.568 7.343 7.343 0 002.856-.569c.338-.143.604-.287.79-.399a3.5 3.5 0 00.31-.206.75.75 0 00.23-.896L20.07 7.5h1.578a.75.75 0 000-1.5h-4.102a.25.25 0 01-.14-.043l-1.697-1.154a1.75 1.75 0 00-.984-.303H12.75V2.75zM2.193 15.198a5.418 5.418 0 002.557.635 5.418 5.418 0 002.557-.635L4.75 9.368l-2.557 5.83zm14.51-.024c.082.04.174.083.275.126.53.223 1.305.45 2.272.45a5.846 5.846 0 002.547-.576L19.25 9.367l-2.547 5.807z"></path>
|
47 |
+
</svg>
|
48 |
+
<p class="text-small color-fg-muted mb-0 lh-condensed-ultra">
|
49 |
+
richzhang/colorization
|
50 |
+
is licensed under the
|
51 |
+
</p>
|
52 |
+
<h3 class="mt-0 mb-2 h4">BSD 2-Clause "Simplified" License</h3>
|
53 |
+
<p class="mb-0 color-fg-muted text-small pr-2">A permissive license that comes in two variants, the BSD 2-Clause and BSD 3-Clause. Both have very minute differences to the MIT license.</p>
|
54 |
+
</div>
|
55 |
+
|
56 |
+
<div class="d-flex px-3 col-md-6 flex-column flex-sm-row pb-sm-3">
|
57 |
+
<div class="pb-3 col-sm-4 pt-md-2">
|
58 |
+
<h4 class="mt-1 mb-2 h5">Permissions</h4>
|
59 |
+
<ul class="list-style-none">
|
60 |
+
<li class="text-small pl-3">
|
61 |
+
<svg width="13" class="octicon octicon-check color-fg-success ml-n3 v-align-middle" viewBox="0 0 16 16" version="1.1" height="13" aria-hidden="true"><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></svg>
|
62 |
+
<span class="v-align-middle" title="The licensed material and derivatives may be used for commercial purposes.">
|
63 |
+
Commercial use
|
64 |
+
</span>
|
65 |
+
</li>
|
66 |
+
<li class="text-small pl-3">
|
67 |
+
<svg width="13" class="octicon octicon-check color-fg-success ml-n3 v-align-middle" viewBox="0 0 16 16" version="1.1" height="13" aria-hidden="true"><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></svg>
|
68 |
+
<span class="v-align-middle" title="The licensed material may be modified.">
|
69 |
+
Modification
|
70 |
+
</span>
|
71 |
+
</li>
|
72 |
+
<li class="text-small pl-3">
|
73 |
+
<svg width="13" class="octicon octicon-check color-fg-success ml-n3 v-align-middle" viewBox="0 0 16 16" version="1.1" height="13" aria-hidden="true"><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></svg>
|
74 |
+
<span class="v-align-middle" title="The licensed material may be distributed.">
|
75 |
+
Distribution
|
76 |
+
</span>
|
77 |
+
</li>
|
78 |
+
<li class="text-small pl-3">
|
79 |
+
<svg width="13" class="octicon octicon-check color-fg-success ml-n3 v-align-middle" viewBox="0 0 16 16" version="1.1" height="13" aria-hidden="true"><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></svg>
|
80 |
+
<span class="v-align-middle" title="The licensed material may be used and modified in private.">
|
81 |
+
Private use
|
82 |
+
</span>
|
83 |
+
</li>
|
84 |
+
</ul>
|
85 |
+
</div>
|
86 |
+
<div class="pb-3 col-sm-4 pt-md-2">
|
87 |
+
<h4 class="mt-1 mb-2 h5">Limitations</h4>
|
88 |
+
<ul class="list-style-none">
|
89 |
+
<li class="text-small pl-3">
|
90 |
+
<svg width="13" class="octicon octicon-x color-fg-danger ml-n3 v-align-middle" viewBox="0 0 16 16" version="1.1" height="13" aria-hidden="true"><path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path></svg>
|
91 |
+
<span class="v-align-middle" title="This license includes a limitation of liability.">
|
92 |
+
Liability
|
93 |
+
</span>
|
94 |
+
</li>
|
95 |
+
<li class="text-small pl-3">
|
96 |
+
<svg width="13" class="octicon octicon-x color-fg-danger ml-n3 v-align-middle" viewBox="0 0 16 16" version="1.1" height="13" aria-hidden="true"><path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path></svg>
|
97 |
+
<span class="v-align-middle" title="This license explicitly states that it does NOT provide any warranty.">
|
98 |
+
Warranty
|
99 |
+
</span>
|
100 |
+
</li>
|
101 |
+
</ul>
|
102 |
+
</div>
|
103 |
+
<div class="pb-3 col-sm-4 pt-md-2">
|
104 |
+
<h4 class="mt-1 mb-2 h5">Conditions</h4>
|
105 |
+
<ul class="list-style-none">
|
106 |
+
<li class="text-small pl-3">
|
107 |
+
<svg width="13" class="octicon octicon-info color-fg-accent ml-n3 v-align-middle" viewBox="0 0 16 16" version="1.1" height="13" aria-hidden="true"><path fill-rule="evenodd" d="M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm6.5-.25A.75.75 0 017.25 7h1a.75.75 0 01.75.75v2.75h.25a.75.75 0 010 1.5h-2a.75.75 0 010-1.5h.25v-2h-.25a.75.75 0 01-.75-.75zM8 6a1 1 0 100-2 1 1 0 000 2z"></path></svg>
|
108 |
+
<span class="v-align-middle" title="A copy of the license and copyright notice must be included with the licensed material.">
|
109 |
+
License and copyright notice
|
110 |
+
</span>
|
111 |
+
</li>
|
112 |
+
</ul>
|
113 |
+
</div>
|
114 |
+
</div>
|
115 |
+
</div>. For the full list of restrictions please <a href="https://github.dev/richzhang/colorization/blob/master/LICENSE" target="_blank" style="text-decoration: underline;" target="_blank">read the license</a></p>
|
116 |
+
</div>
|
117 |
+
<a href="https://arxiv.org/abs/1603.08511"><img class="layered-paper-big" style="height:175px" src="./resources/images/paper_pdf_thumb.png"></a>
|
118 |
+
[![GitHub Stars](https://img.shields.io/github/stars/richzhang/colorization?style=social)](https://github.com/richzhang/colorization)
|
119 |
+
|
120 |
+
<br>
|
121 |
+
<center><img src='https://visitor-badge.glitch.me/badge?page_id=dj_colorization_eccv16siggraph17' alt='visitor badge'></center>
|
122 |
+
"""
|
123 |
+
|
124 |
+
interface = gr.Interface(
|
125 |
interface,
|
126 |
[
|
127 |
gr.components.Image(type="pil", label="image"),
|
|
|
133 |
],
|
134 |
[
|
135 |
gr.components.Image(label="output")
|
136 |
+
],
|
137 |
+
|
138 |
+
)
|
139 |
+
interface.launch(share=True)
|
140 |
+
|
141 |
+
|
142 |
+
interface = gr.Interface(
|
143 |
+
predict,
|
144 |
+
inputs="sketchpad",
|
145 |
+
outputs="label",
|
146 |
+
theme="huggingface",
|
147 |
+
title=title,
|
148 |
+
description=description,
|
149 |
+
article=article,
|
150 |
+
live=True,
|
151 |
+
)
|
152 |
+
interface.launch(share=True)
|