Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,11 +17,16 @@ import PIL.Image
|
|
| 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 = 'yo2266911/DeepDanbooru_string'
|
| 25 |
MODEL_FILENAME = 'model-resnet_custom_v3.h5'
|
| 26 |
LABEL_FILENAME = 'tags.txt'
|
| 27 |
|
|
@@ -95,7 +100,6 @@ def predict(image: PIL.Image.Image, score_threshold: float,
|
|
| 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,7 +136,7 @@ def predict(image: PIL.Image.Image, score_threshold: float,
|
|
| 132 |
message = "Nothing found in the image."
|
| 133 |
info = f"<div><p>{message}<p></div>"
|
| 134 |
|
| 135 |
-
return (a,
|
| 136 |
|
| 137 |
|
| 138 |
def main():
|
|
@@ -154,10 +158,9 @@ def main():
|
|
| 154 |
label='Score Threshold'),
|
| 155 |
],
|
| 156 |
[
|
| 157 |
-
gr.outputs.
|
| 158 |
-
gr.outputs.Textbox(label='Output (
|
| 159 |
-
gr.outputs.Label(label='Output (label)')
|
| 160 |
-
gr.outputs.HTML()
|
| 161 |
],
|
| 162 |
examples=[
|
| 163 |
['miku.jpg',0.5],
|
|
@@ -168,7 +171,6 @@ def main():
|
|
| 168 |
Demo for [KichangKim/DeepDanbooru](https://github.com/KichangKim/DeepDanbooru) with "ready to copy" prompt and a prompt analyzer.
|
| 169 |
|
| 170 |
Modified from [hysts/DeepDanbooru](https://huggingface.co/spaces/hysts/DeepDanbooru)
|
| 171 |
-
|
| 172 |
PNG Info code forked from [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
|
| 173 |
''',
|
| 174 |
theme=args.theme,
|
|
|
|
| 17 |
import tensorflow as tf
|
| 18 |
import piexif
|
| 19 |
import piexif.helper
|
| 20 |
+
import re
|
| 21 |
|
| 22 |
TITLE = 'DeepDanbooru String'
|
| 23 |
|
| 24 |
+
url = 'https://huggingface.co/spaces/yo2266911/DeepDanbooru_string/'
|
| 25 |
+
repo_id, repo_type = re.findall(r'https://huggingface.co/([^/]+)/([^/]+)/', url)
|
| 26 |
+
print(f'Repository ID: {repo_id}')
|
| 27 |
+
print(f'Repository type: {repo_type}')
|
| 28 |
+
MODEL_REPO = f'{repo_id}/{repo_type}'
|
| 29 |
TOKEN = os.environ['TOKEN']
|
|
|
|
| 30 |
MODEL_FILENAME = 'model-resnet_custom_v3.h5'
|
| 31 |
LABEL_FILENAME = 'tags.txt'
|
| 32 |
|
|
|
|
| 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 |
message = "Nothing found in the image."
|
| 137 |
info = f"<div><p>{message}<p></div>"
|
| 138 |
|
| 139 |
+
return (info,a,res)
|
| 140 |
|
| 141 |
|
| 142 |
def main():
|
|
|
|
| 158 |
label='Score Threshold'),
|
| 159 |
],
|
| 160 |
[
|
| 161 |
+
gr.outputs.HTML(),
|
| 162 |
+
gr.outputs.Textbox(label='DeepDanbooru Output (string)'),
|
| 163 |
+
gr.outputs.Label(label='DeepDanbooru Output (label)')
|
|
|
|
| 164 |
],
|
| 165 |
examples=[
|
| 166 |
['miku.jpg',0.5],
|
|
|
|
| 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 |
''',
|
| 176 |
theme=args.theme,
|