Thouph commited on
Commit
ca2965c
1 Parent(s): a11578c
Files changed (3) hide show
  1. efnet_step_86400.pth +3 -0
  2. inference.py +44 -0
  3. tags.txt +105 -0
efnet_step_86400.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d43954ae99774d23919f9b9ce2b39edf469ade3fae2496948b87e1b29079f8d0
3
+ size 214488367
inference.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ from PIL import Image
3
+ from timm.data import resolve_data_config
4
+ import torch
5
+ from torchvision.transforms import transforms
6
+
7
+ model = torch.load('path/to/model.pth')
8
+ model.eval()
9
+
10
+ config = resolve_data_config({}, model=model)
11
+ transform = transforms.Compose([
12
+ transforms.Resize((224, 224)),
13
+ transforms.ToTensor(),
14
+ transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) # Normalize image
15
+ ])
16
+
17
+
18
+ with open("tags.txt", "r") as f:
19
+ categories = [s.strip() for s in f.readlines()]
20
+ categories=sorted(categories)
21
+
22
+
23
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
24
+
25
+ images=["your_image_here.jpg", "your_second_image_here.jpg"]
26
+
27
+ for item in images:
28
+ start = time.time()
29
+ img = Image.open(item).convert('RGB')
30
+ tensor = transform(img).unsqueeze(0).to(device) # transform and add batch dimension
31
+
32
+ with torch.no_grad():
33
+ out = model(tensor)
34
+ probabilities = torch.nn.functional.sigmoid(out[0])
35
+ print(probabilities.shape)
36
+
37
+
38
+ top10_prob, top10_catid = torch.topk(probabilities, 10)
39
+ for i in range(top10_prob.size(0)):
40
+ print(categories[top10_catid[i]], top10_prob[i].item())
41
+
42
+ end = time.time()
43
+ print(f'Executed in {end - start} seconds')
44
+ print("\n\n", end="")
tags.txt ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ male
2
+ female
3
+ anthro
4
+ breasts
5
+ solo
6
+ canine
7
+ cock
8
+ sex
9
+ pussy
10
+ pokemon
11
+ ass
12
+ cute
13
+ thighs
14
+ feet
15
+ paws
16
+ blush
17
+ femboy
18
+ muscles
19
+ size_difference
20
+ pony
21
+ equine
22
+ sfw
23
+ nsfw
24
+ mlp
25
+ public
26
+ pov
27
+ femdom
28
+ scales
29
+ thick_thighs
30
+ genitals
31
+ mammal
32
+ bodily_fluids
33
+ duo
34
+ fur
35
+ clothing
36
+ canid
37
+ hair
38
+ genital_fluids
39
+ nude
40
+ tongue
41
+ simple_background
42
+ looking_at_viewer
43
+ smile
44
+ canis
45
+ male/male
46
+ claws
47
+ teeth
48
+ male/female
49
+ felid
50
+ muscular
51
+ tuft
52
+ wolf
53
+ dragon
54
+ pawpads
55
+ muscular_male
56
+ legwear
57
+ fox
58
+ grey_body
59
+ precum
60
+ solo_focus
61
+ black_nose
62
+ 4_toes
63
+ grey_fur
64
+ shirt
65
+ muscular_anthro
66
+ abs
67
+ wings
68
+ eyelashes
69
+ jewelry
70
+ brown_hair
71
+ raised_tail
72
+ felis
73
+ ambiguous_gender
74
+ submissive
75
+ headgear
76
+ partially_clothed
77
+ white_background
78
+ thigh_highs
79
+ glasses
80
+ seductive
81
+ two_tone_fur
82
+ smaller_male
83
+ equine_penis
84
+ bdsm
85
+ generation_1_pokemon
86
+ larger_male
87
+ chest_tuft
88
+ digitigrade
89
+ fluffy
90
+ headwear
91
+ yellow_fur
92
+ drooling
93
+ monochrome
94
+ pink_nipples
95
+ bulge
96
+ biceps
97
+ bedroom_eyes
98
+ blue_hair
99
+ submissive_male
100
+ narrowed_eyes
101
+ underwear
102
+ girly
103
+ detailed_background
104
+ shirt
105
+ bound