Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,24 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
pipe = pipeline("image-classification", "umm-maybe/AI-image-detector")
|
| 5 |
+
|
| 6 |
+
def image_classifier(image):
|
| 7 |
+
outputs = pipe(image)
|
| 8 |
+
results = {}
|
| 9 |
+
for result in outputs:
|
| 10 |
+
results[result['label']] = result['score']
|
| 11 |
+
return results
|
| 12 |
+
|
| 13 |
+
title = "Maybe's AI Art Detector"
|
| 14 |
+
description = """
|
| 15 |
+
This app is a proof-of-concept demonstration of using a ViT model to predict whether an artistic image was generated using AI.
|
| 16 |
+
It was created in October 2022, and as such, the training data did not include any samples generated by Midjourney 5, SDXL, or DALLE-3. It still may be able to correctly identify samples from these more recent models due to being trained on outputs of their predecessors.
|
| 17 |
+
Furthermore the intended scope of this tool is artistic images; that is to say, it is not a deepfake photo detector, and general computer imagery (webcams, screenshots, etc.) may throw it off.
|
| 18 |
+
In general, this tool can only serve as one of many potential indicators that an image was AI-generated. Images scoring as very probably artificial (e.g. 90% or higher) could be referred to a human expert for further investigation, if needed.
|
| 19 |
+
For more information please see the blog post describing this project at:
|
| 20 |
+
https://medium.com/@matthewmaybe/can-an-ai-learn-to-identify-ai-art-545d9d6af226
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="label", title=title, description=description)
|
| 24 |
+
demo.launch(show_api=False)
|