RomanShnurov commited on
Commit
e6058f6
1 Parent(s): f3b2c5b

some polishes

Browse files
Files changed (2) hide show
  1. app.py +0 -14
  2. requirements.txt +2 -1
app.py CHANGED
@@ -3,20 +3,6 @@ from torch.nn import functional as F
3
 
4
  from model_loader import ModelType, type_to_transforms, type_to_loaded_model
5
 
6
- def predict_from_model(model_type, raw_image):
7
- tfm = type_to_transforms[model_type]
8
- model = type_to_loaded_model[model_type]
9
- img = tfm(raw_image)
10
- y = None
11
- if model_type == ModelType.SYNTHETIC_DETECTOR_V2:
12
- y = model.forward(img.unsqueeze(0).to("cpu"))
13
- else:
14
- y = model.forward(img[None, ...])
15
- y_1 = F.softmax(y, dim=1)[:, 1].cpu().detach().numpy()
16
- y_2 = F.softmax(y, dim=1)[:, 0].cpu().detach().numpy()
17
- return {'created by AI': y_1.tolist(),
18
- 'created by human': y_2.tolist()}
19
-
20
  def get_y(model_type, model, image):
21
  if model_type == ModelType.SYNTHETIC_DETECTOR_V2:
22
  return model.forward(image.unsqueeze(0).to("cpu"))
 
3
 
4
  from model_loader import ModelType, type_to_transforms, type_to_loaded_model
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  def get_y(model_type, model, image):
7
  if model_type == ModelType.SYNTHETIC_DETECTOR_V2:
8
  return model.forward(image.unsqueeze(0).to("cpu"))
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  timm==0.9.5
2
  torch==2.0.1
3
- torchvision==0.15.2
 
 
1
  timm==0.9.5
2
  torch==2.0.1
3
+ torchvision==0.15.2
4
+ pytorch-lightning==2.0.9