Spaces:
Running
Running
change examples
Browse files- app.py +25 -15
- examples/fake/facial.jpg +0 -0
- examples/fake/facial1.png +0 -0
- examples/fake/facial2.jpg +0 -0
- examples/fake/{general.jpg → general1.jpg} +0 -0
- examples/fake/general2.jpg +0 -0
- examples/real/facial.jpg +0 -0
- examples/real/facial1.jpg +0 -0
- examples/real/facial2.jpg +0 -0
- examples/real/{general.jpg → general1.jpg} +0 -0
- examples/real/general2.jpg +0 -0
app.py
CHANGED
|
@@ -90,13 +90,11 @@ def process_example(image_path):
|
|
| 90 |
model_type = determine_model_type(image_path)
|
| 91 |
return Image.open(image_path), model_type
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
"examples/fake
|
| 96 |
-
|
| 97 |
-
"examples/real
|
| 98 |
-
"examples/real/general.jpg",
|
| 99 |
-
]
|
| 100 |
|
| 101 |
with gr.Blocks() as demo:
|
| 102 |
|
|
@@ -105,22 +103,34 @@ with gr.Blocks() as demo:
|
|
| 105 |
input_type = gr.Radio(["Image", "Video"], label="Choose Input Type", value="Image")
|
| 106 |
|
| 107 |
model_type = gr.Radio(["Facial", "General"], label="Choose Model Type", value="General")
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
|
|
|
| 112 |
process_button = gr.Button("Run Model")
|
| 113 |
|
| 114 |
-
pred_score_output = gr.Textbox(label="Prediction Score")
|
| 115 |
-
attn_map_output = gr.Image(type="pil", label="Attention Map")
|
| 116 |
|
| 117 |
# Example Images 추가
|
| 118 |
gr.Examples(
|
| 119 |
-
examples=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
inputs=[image_input],
|
| 121 |
outputs=[image_input, model_type],
|
| 122 |
fn=process_example,
|
| 123 |
-
cache_examples=False
|
|
|
|
|
|
|
| 124 |
)
|
| 125 |
|
| 126 |
input_type.change(fn=change_input, inputs=[input_type], outputs=[image_input, video_input])
|
|
|
|
| 90 |
model_type = determine_model_type(image_path)
|
| 91 |
return Image.open(image_path), model_type
|
| 92 |
|
| 93 |
+
fake_examples, real_examples = [], []
|
| 94 |
+
for example in os.listdir("examples/fake"):
|
| 95 |
+
fake_examples.append(os.path.join("examples/fake", example))
|
| 96 |
+
for example in os.listdir("examples/real"):
|
| 97 |
+
real_examples.append(os.path.join("examples/real", example))
|
|
|
|
|
|
|
| 98 |
|
| 99 |
with gr.Blocks() as demo:
|
| 100 |
|
|
|
|
| 103 |
input_type = gr.Radio(["Image", "Video"], label="Choose Input Type", value="Image")
|
| 104 |
|
| 105 |
model_type = gr.Radio(["Facial", "General"], label="Choose Model Type", value="General")
|
| 106 |
+
|
| 107 |
+
H, W = 300, 300
|
| 108 |
+
image_input = gr.Image(type="pil", label="Upload Image", visible=True, height=H, width=W)
|
| 109 |
+
video_input = gr.Video(label="Upload Video", visible=False, height=H, width=W)
|
| 110 |
+
|
| 111 |
process_button = gr.Button("Run Model")
|
| 112 |
|
| 113 |
+
pred_score_output = gr.Textbox(label="Prediction Score : 0 - REAL, 1 - FAKE")
|
| 114 |
+
attn_map_output = gr.Image(type="pil", label="Attention Map", height=H, width=W)
|
| 115 |
|
| 116 |
# Example Images 추가
|
| 117 |
gr.Examples(
|
| 118 |
+
examples=fake_examples,
|
| 119 |
+
inputs=[image_input],
|
| 120 |
+
outputs=[image_input, model_type],
|
| 121 |
+
fn=process_example,
|
| 122 |
+
cache_examples=False,
|
| 123 |
+
examples_per_page=10,
|
| 124 |
+
label="Fake Examples"
|
| 125 |
+
)
|
| 126 |
+
gr.Examples(
|
| 127 |
+
examples=real_examples,
|
| 128 |
inputs=[image_input],
|
| 129 |
outputs=[image_input, model_type],
|
| 130 |
fn=process_example,
|
| 131 |
+
cache_examples=False,
|
| 132 |
+
examples_per_page=10,
|
| 133 |
+
label="Real Examples"
|
| 134 |
)
|
| 135 |
|
| 136 |
input_type.change(fn=change_input, inputs=[input_type], outputs=[image_input, video_input])
|
examples/fake/facial.jpg
DELETED
|
Binary file (127 kB)
|
|
|
examples/fake/facial1.png
ADDED
|
examples/fake/facial2.jpg
ADDED
|
examples/fake/{general.jpg → general1.jpg}
RENAMED
|
File without changes
|
examples/fake/general2.jpg
ADDED
|
examples/real/facial.jpg
DELETED
|
Binary file (66.4 kB)
|
|
|
examples/real/facial1.jpg
ADDED
|
examples/real/facial2.jpg
ADDED
|
examples/real/{general.jpg → general1.jpg}
RENAMED
|
File without changes
|
examples/real/general2.jpg
ADDED
|