Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,16 +17,11 @@ import PIL.Image
|
|
| 17 |
import tensorflow as tf
|
| 18 |
import piexif
|
| 19 |
import piexif.helper
|
| 20 |
-
import re
|
| 21 |
|
| 22 |
TITLE = 'DeepDanbooru String'
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
repo_id = matches[0][1]
|
| 27 |
-
repo_type = matches[0][2]
|
| 28 |
-
MODEL_REPO = f'{repo_id}/{repo_type}'
|
| 29 |
-
TOKEN = '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'
|
| 30 |
MODEL_FILENAME = 'model-resnet_custom_v3.h5'
|
| 31 |
LABEL_FILENAME = 'tags.txt'
|
| 32 |
|
|
@@ -100,6 +95,7 @@ def predict(image: PIL.Image.Image, score_threshold: float,
|
|
| 100 |
res[label] = prob
|
| 101 |
b = dict(sorted(res.items(),key=lambda item:item[1], reverse=True))
|
| 102 |
a = ', '.join(list(b.keys())).replace('_',' ').replace('(','\(').replace(')','\)')
|
|
|
|
| 103 |
|
| 104 |
items = rawimage.info
|
| 105 |
geninfo = ''
|
|
@@ -136,7 +132,7 @@ def predict(image: PIL.Image.Image, score_threshold: float,
|
|
| 136 |
message = "Nothing found in the image."
|
| 137 |
info = f"<div><p>{message}<p></div>"
|
| 138 |
|
| 139 |
-
return (
|
| 140 |
|
| 141 |
|
| 142 |
def main():
|
|
@@ -158,9 +154,10 @@ def main():
|
|
| 158 |
label='Score Threshold'),
|
| 159 |
],
|
| 160 |
[
|
| 161 |
-
gr.outputs.
|
| 162 |
-
gr.outputs.Textbox(label='
|
| 163 |
-
gr.outputs.Label(label='
|
|
|
|
| 164 |
],
|
| 165 |
examples=[
|
| 166 |
['miku.jpg',0.5],
|
|
@@ -169,7 +166,6 @@ def main():
|
|
| 169 |
title=TITLE,
|
| 170 |
description='''
|
| 171 |
Demo for [KichangKim/DeepDanbooru](https://github.com/KichangKim/DeepDanbooru) with "ready to copy" prompt and a prompt analyzer.
|
| 172 |
-
|
| 173 |
Modified from [hysts/DeepDanbooru](https://huggingface.co/spaces/hysts/DeepDanbooru)
|
| 174 |
PNG Info code forked from [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
|
| 175 |
''',
|
|
|
|
| 17 |
import tensorflow as tf
|
| 18 |
import piexif
|
| 19 |
import piexif.helper
|
|
|
|
| 20 |
|
| 21 |
TITLE = 'DeepDanbooru String'
|
| 22 |
|
| 23 |
+
TOKEN = os.environ['TOKEN']
|
| 24 |
+
MODEL_REPO = 'NoCrypt/DeepDanbooru_string'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
MODEL_FILENAME = 'model-resnet_custom_v3.h5'
|
| 26 |
LABEL_FILENAME = 'tags.txt'
|
| 27 |
|
|
|
|
| 95 |
res[label] = prob
|
| 96 |
b = dict(sorted(res.items(),key=lambda item:item[1], reverse=True))
|
| 97 |
a = ', '.join(list(b.keys())).replace('_',' ').replace('(','\(').replace(')','\)')
|
| 98 |
+
c = ', '.join(list(b.keys()))
|
| 99 |
|
| 100 |
items = rawimage.info
|
| 101 |
geninfo = ''
|
|
|
|
| 132 |
message = "Nothing found in the image."
|
| 133 |
info = f"<div><p>{message}<p></div>"
|
| 134 |
|
| 135 |
+
return (a,c,res,info)
|
| 136 |
|
| 137 |
|
| 138 |
def main():
|
|
|
|
| 154 |
label='Score Threshold'),
|
| 155 |
],
|
| 156 |
[
|
| 157 |
+
gr.outputs.Textbox(label='Output (string)'),
|
| 158 |
+
gr.outputs.Textbox(label='Output (raw string)'),
|
| 159 |
+
gr.outputs.Label(label='Output (label)'),
|
| 160 |
+
gr.outputs.HTML()
|
| 161 |
],
|
| 162 |
examples=[
|
| 163 |
['miku.jpg',0.5],
|
|
|
|
| 166 |
title=TITLE,
|
| 167 |
description='''
|
| 168 |
Demo for [KichangKim/DeepDanbooru](https://github.com/KichangKim/DeepDanbooru) with "ready to copy" prompt and a prompt analyzer.
|
|
|
|
| 169 |
Modified from [hysts/DeepDanbooru](https://huggingface.co/spaces/hysts/DeepDanbooru)
|
| 170 |
PNG Info code forked from [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
|
| 171 |
''',
|