Omnibus commited on
Commit
53c3b30
1 Parent(s): 836257c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -6,8 +6,9 @@ models=[
6
  "Nahrawy/AIorNot",
7
  "RishiDarkDevil/ai-image-det-resnet152",
8
  "arnolfokam/ai-generated-image-detector",
 
9
  ]
10
- pipe = pipeline("image-classification", "umm-maybe/AI-image-detector")
11
 
12
  def image_classifier(image):
13
  outputs = pipe(image)
@@ -28,13 +29,14 @@ def aiornot(image,mod_choose):
28
 
29
  #feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
30
  mod=models[int(mod_choose)]
31
- feature_extractor = AutoFeatureExtractor.from_pretrained("Nahrawy/AIorNot")
32
- model = AutoModelForImageClassification.from_pretrained("Nahrawy/AIorNot")
33
 
34
  input = feature_extractor(image, return_tensors="pt")
35
  with torch.no_grad():
36
  outputs = model(**input)
37
  logits = outputs.logits
 
38
  prediction = logits.argmax(-1).item()
39
  label = labels[prediction]
40
  return label
 
6
  "Nahrawy/AIorNot",
7
  "RishiDarkDevil/ai-image-det-resnet152",
8
  "arnolfokam/ai-generated-image-detector",
9
+ "umm-maybe/AI-image-detector",
10
  ]
11
+ #pipe = pipeline("image-classification", "umm-maybe/AI-image-detector")
12
 
13
  def image_classifier(image):
14
  outputs = pipe(image)
 
29
 
30
  #feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
31
  mod=models[int(mod_choose)]
32
+ feature_extractor = AutoFeatureExtractor.from_pretrained(mod)
33
+ model = AutoModelForImageClassification.from_pretrained(mod)
34
 
35
  input = feature_extractor(image, return_tensors="pt")
36
  with torch.no_grad():
37
  outputs = model(**input)
38
  logits = outputs.logits
39
+ print (logits)
40
  prediction = logits.argmax(-1).item()
41
  label = labels[prediction]
42
  return label