Omnibus commited on
Commit
b69e293
1 Parent(s): 2671156

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -17,16 +17,16 @@ models=[
17
  def aiornot0(image):
18
  labels = ["Real", "AI"]
19
  mod=models[0]
20
- feature_extractor = AutoFeatureExtractor.from_pretrained(mod)
21
- model = AutoModelForImageClassification.from_pretrained(mod)
22
- input = feature_extractor(image, return_tensors="pt")
23
  with torch.no_grad():
24
- outputs = model(**input)
25
  print (outputs)
26
  logits = outputs.logits
27
  print (logits)
28
  probability = softmax(logits)
29
- print(probability)
30
 
31
  prediction = logits.argmax(-1).item()
32
  label = labels[prediction]
@@ -34,11 +34,11 @@ def aiornot0(image):
34
  def aiornot1(image):
35
  labels = ["Real", "AI"]
36
  mod=models[1]
37
- feature_extractor = AutoFeatureExtractor.from_pretrained(mod)
38
- model = AutoModelForImageClassification.from_pretrained(mod)
39
- input = feature_extractor(image, return_tensors="pt")
40
  with torch.no_grad():
41
- outputs = model(**input)
42
  print (outputs)
43
  logits = outputs.logits
44
  print (logits)
@@ -48,11 +48,11 @@ def aiornot1(image):
48
  def aiornot2(image):
49
  labels = ["Real", "AI"]
50
  mod=models[2]
51
- feature_extractor = AutoFeatureExtractor.from_pretrained(mod)
52
- model = AutoModelForImageClassification.from_pretrained(mod)
53
- input = feature_extractor(image, return_tensors="pt")
54
  with torch.no_grad():
55
- outputs = model(**input)
56
  print (outputs)
57
  logits = outputs.logits
58
  print (logits)
 
17
  def aiornot0(image):
18
  labels = ["Real", "AI"]
19
  mod=models[0]
20
+ feature_extractor0 = AutoFeatureExtractor.from_pretrained(mod)
21
+ model0 = AutoModelForImageClassification.from_pretrained(mod)
22
+ input = feature_extractor0(image, return_tensors="pt")
23
  with torch.no_grad():
24
+ outputs = model0(**input)
25
  print (outputs)
26
  logits = outputs.logits
27
  print (logits)
28
  probability = softmax(logits)
29
+ print(f'PROBABILITY ::: {probability}')
30
 
31
  prediction = logits.argmax(-1).item()
32
  label = labels[prediction]
 
34
  def aiornot1(image):
35
  labels = ["Real", "AI"]
36
  mod=models[1]
37
+ feature_extractor1 = AutoFeatureExtractor.from_pretrained(mod)
38
+ model1 = AutoModelForImageClassification.from_pretrained(mod)
39
+ input = feature_extractor1(image, return_tensors="pt")
40
  with torch.no_grad():
41
+ outputs = model1(**input)
42
  print (outputs)
43
  logits = outputs.logits
44
  print (logits)
 
48
  def aiornot2(image):
49
  labels = ["Real", "AI"]
50
  mod=models[2]
51
+ feature_extractor2 = AutoFeatureExtractor.from_pretrained(mod)
52
+ model2 = AutoModelForImageClassification.from_pretrained(mod)
53
+ input = feature_extractor2(image, return_tensors="pt")
54
  with torch.no_grad():
55
+ outputs = model2(**input)
56
  print (outputs)
57
  logits = outputs.logits
58
  print (logits)