Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,20 @@ from pytorch_grad_cam import GradCAM
|
|
11 |
from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
|
12 |
from pytorch_grad_cam.utils.image import show_cam_on_image
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
#gr.themes.Soft()
|
15 |
#gr.themes.builder()
|
16 |
|
@@ -97,6 +111,9 @@ title = "Deepfake Image Detection"
|
|
97 |
description = "~ AI - ML implementation for fake and real image detection..."
|
98 |
article = "<p style='text-align: center'>...</p>"
|
99 |
|
|
|
|
|
|
|
100 |
interface = gr.Interface(
|
101 |
fn=predict,
|
102 |
inputs=[
|
@@ -109,6 +126,7 @@ interface = gr.Interface(
|
|
109 |
gr.outputs.Image(label="Face with Explainability", type="pil")
|
110 |
#ValueError: Invalid value for parameter `type`: auto. Please choose from one of: ['numpy', 'pil', 'filepath']
|
111 |
],
|
|
|
112 |
theme = gr.themes.Soft(),
|
113 |
title = title,
|
114 |
description = description,
|
|
|
11 |
from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
|
12 |
from pytorch_grad_cam.utils.image import show_cam_on_image
|
13 |
|
14 |
+
#ai-pict-detect
|
15 |
+
from transformers import pipeline
|
16 |
+
|
17 |
+
pipe = pipeline("image-classification", "nightfury/AI-picture-detector")
|
18 |
+
|
19 |
+
def image_classifier(image):
|
20 |
+
outputs = pipe(image)
|
21 |
+
results = {}
|
22 |
+
for result in outputs:
|
23 |
+
results[result['label']] = result['score']
|
24 |
+
return results
|
25 |
+
#ai-pict-detect
|
26 |
+
|
27 |
+
|
28 |
#gr.themes.Soft()
|
29 |
#gr.themes.builder()
|
30 |
|
|
|
111 |
description = "~ AI - ML implementation for fake and real image detection..."
|
112 |
article = "<p style='text-align: center'>...</p>"
|
113 |
|
114 |
+
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="label", title=title, description=description)
|
115 |
+
demo.launch(show_api=False)
|
116 |
+
|
117 |
interface = gr.Interface(
|
118 |
fn=predict,
|
119 |
inputs=[
|
|
|
126 |
gr.outputs.Image(label="Face with Explainability", type="pil")
|
127 |
#ValueError: Invalid value for parameter `type`: auto. Please choose from one of: ['numpy', 'pil', 'filepath']
|
128 |
],
|
129 |
+
|
130 |
theme = gr.themes.Soft(),
|
131 |
title = title,
|
132 |
description = description,
|