Spaces:
Runtime error
Runtime error
pengdaqian commited on
Commit ·
b280673
1
Parent(s): 2f7f154
warm up model
Browse files- Dockerfile +3 -0
- dbimutils.py +2 -1
- warm_up.py +17 -0
Dockerfile
CHANGED
|
@@ -13,4 +13,7 @@ WORKDIR $HOME/app
|
|
| 13 |
|
| 14 |
COPY --chown=user . $HOME/app
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
CMD ["sh", "-c", "python3 main.py"]
|
|
|
|
| 13 |
|
| 14 |
COPY --chown=user . $HOME/app
|
| 15 |
|
| 16 |
+
# cache model
|
| 17 |
+
RUN python3 warm_up.py
|
| 18 |
+
|
| 19 |
CMD ["sh", "-c", "python3 main.py"]
|
dbimutils.py
CHANGED
|
@@ -65,5 +65,6 @@ def read_img_from_url(image):
|
|
| 65 |
rawimage = Image.open(io.BytesIO(res.content))
|
| 66 |
return rawimage
|
| 67 |
else:
|
| 68 |
-
|
|
|
|
| 69 |
return image
|
|
|
|
| 65 |
rawimage = Image.open(io.BytesIO(res.content))
|
| 66 |
return rawimage
|
| 67 |
else:
|
| 68 |
+
res = Image.open(image)
|
| 69 |
+
return rawimage
|
| 70 |
return image
|
warm_up.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import img_label
|
| 2 |
+
from img_nsfw import init_nsfw_pipe, check_nsfw
|
| 3 |
+
|
| 4 |
+
if __name__ == "__main__":
|
| 5 |
+
img = 'test.jpeg'
|
| 6 |
+
pipe = init_nsfw_pipe()
|
| 7 |
+
nsfw_tags = check_nsfw(img, pipe)
|
| 8 |
+
|
| 9 |
+
score_general_threshold = 0.35
|
| 10 |
+
score_character_threshold = 0.85
|
| 11 |
+
|
| 12 |
+
img_tags = img_label.label_img(
|
| 13 |
+
image=img,
|
| 14 |
+
model="SwinV2",
|
| 15 |
+
l_score_general_threshold=score_general_threshold,
|
| 16 |
+
l_score_character_threshold=score_character_threshold,
|
| 17 |
+
)['general_res']
|