Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,20 @@ import gradio as gr
|
|
| 2 |
import torch
|
| 3 |
from transformers import AutoFeatureExtractor, AutoModelForImageClassification
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
labels = ["Real", "AI"]
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
model = AutoModelForImageClassification.from_pretrained("Nahrawy/AIorNot")
|
| 9 |
|
| 10 |
input = feature_extractor(image, return_tensors="pt")
|
|
@@ -17,8 +28,10 @@ def aiornot(img):
|
|
| 17 |
|
| 18 |
with gr.Blocks() as app:
|
| 19 |
with gr.Row():
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
outp = gr.Textbox()
|
| 23 |
-
btn.click(aiornot,inp,outp)
|
| 24 |
app.launch()
|
|
|
|
| 2 |
import torch
|
| 3 |
from transformers import AutoFeatureExtractor, AutoModelForImageClassification
|
| 4 |
|
| 5 |
+
models=[
|
| 6 |
+
"Nahrawy/AIorNot",
|
| 7 |
+
"RishiDarkDevil/ai-image-det-resnet152",
|
| 8 |
+
"arnolfokam/ai-generated-image-detector",
|
| 9 |
+
]
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def aiornot(img,mod_choose):
|
| 14 |
labels = ["Real", "AI"]
|
| 15 |
+
|
| 16 |
+
#feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
|
| 17 |
+
mod=models[int(mod_choose)]
|
| 18 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(models[])
|
| 19 |
model = AutoModelForImageClassification.from_pretrained("Nahrawy/AIorNot")
|
| 20 |
|
| 21 |
input = feature_extractor(image, return_tensors="pt")
|
|
|
|
| 28 |
|
| 29 |
with gr.Blocks() as app:
|
| 30 |
with gr.Row():
|
| 31 |
+
with gr.Column():
|
| 32 |
+
inp = gr.Image()
|
| 33 |
+
mod_choose=gr.Number(value=0)
|
| 34 |
+
btn = gr.Button()
|
| 35 |
outp = gr.Textbox()
|
| 36 |
+
btn.click(aiornot,[inp,mod_choose],outp)
|
| 37 |
app.launch()
|