Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import requests
|
5 |
import timm
|
6 |
import torch
|
|
|
7 |
|
8 |
nsfw_tf = pipeline(model="carbon225/vit-base-patch16-224-hentai")
|
9 |
|
@@ -21,14 +22,16 @@ if not os.path.exists("timm.ckpt"):
|
|
21 |
else:
|
22 |
print("Model already exists, skipping redownload")
|
23 |
|
|
|
|
|
24 |
|
25 |
nsfw_tm = timm.create_model(
|
26 |
"caformer_s36.sail_in22k_ft_in1k_384",
|
27 |
checkpoint_path="./timm.ckpt",
|
28 |
-
|
29 |
pretrained=True
|
30 |
).eval()
|
31 |
-
tm_config = timm.data.resolve_model_data_config(nsfw_tm
|
32 |
tm_trans = timm.data.create_transform(**tm_config)
|
33 |
|
34 |
|
|
|
4 |
import requests
|
5 |
import timm
|
6 |
import torch
|
7 |
+
import json
|
8 |
|
9 |
nsfw_tf = pipeline(model="carbon225/vit-base-patch16-224-hentai")
|
10 |
|
|
|
22 |
else:
|
23 |
print("Model already exists, skipping redownload")
|
24 |
|
25 |
+
with open("timmcfg.json") as file:
|
26 |
+
tm_cfg = json.load(file)
|
27 |
|
28 |
nsfw_tm = timm.create_model(
|
29 |
"caformer_s36.sail_in22k_ft_in1k_384",
|
30 |
checkpoint_path="./timm.ckpt",
|
31 |
+
model_config=tm_cfg,
|
32 |
pretrained=True
|
33 |
).eval()
|
34 |
+
tm_config = timm.data.resolve_model_data_config(nsfw_tm)
|
35 |
tm_trans = timm.data.create_transform(**tm_config)
|
36 |
|
37 |
|