Spaces:
Running
Running
changed structure and UI
Browse files- app.py +8 -6
- examples/trump-fake.jpeg +0 -0
- models/clip-glide.pth +3 -0
- models/clip-ld.pth +3 -0
- models/clip-sd.pth +3 -0
app.py
CHANGED
@@ -97,7 +97,7 @@ def predict(img, caption):
|
|
97 |
caption = get_caption(img)
|
98 |
print("New caption-->",caption)
|
99 |
prediction=[]
|
100 |
-
models_list = ['clip-sd.pth', 'clip-glide.pth', 'clip-ld.pth']
|
101 |
modality = "Image+Text"
|
102 |
for model_path in models_list:
|
103 |
model = get_model(model_path, modality)
|
@@ -108,18 +108,20 @@ def predict(img, caption):
|
|
108 |
print('------------>', out)
|
109 |
prediction.append(out.item())
|
110 |
|
111 |
-
|
112 |
-
|
|
|
|
|
113 |
else:
|
114 |
-
return "Real"
|
115 |
|
116 |
|
117 |
# Create Gradio interface
|
118 |
-
image_input = gr.Image(type="pil", label="
|
119 |
text_input = gr.Textbox(label="Caption for image (Optional)")
|
120 |
|
121 |
iface = gr.Interface(fn=predict,
|
122 |
inputs=[image_input, text_input],
|
123 |
outputs=gr.Label(),
|
124 |
-
examples=[["trump-fake.jpeg", "Donald Trump being arrested by authorities."]])
|
125 |
iface.launch()
|
|
|
97 |
caption = get_caption(img)
|
98 |
print("New caption-->",caption)
|
99 |
prediction=[]
|
100 |
+
models_list = ['models/clip-sd.pth', 'models/clip-glide.pth', 'models/clip-ld.pth']
|
101 |
modality = "Image+Text"
|
102 |
for model_path in models_list:
|
103 |
model = get_model(model_path, modality)
|
|
|
108 |
print('------------>', out)
|
109 |
prediction.append(out.item())
|
110 |
|
111 |
+
# Count the number of predictions that are greater than or equal to 0.5
|
112 |
+
count_ones = sum(1 for p in prediction if p >= 0.5)
|
113 |
+
if count_ones > len(prediction) / 2:
|
114 |
+
return "Fake Image"
|
115 |
else:
|
116 |
+
return "Real Image "
|
117 |
|
118 |
|
119 |
# Create Gradio interface
|
120 |
+
image_input = gr.Image(type="pil", label="Input Image")
|
121 |
text_input = gr.Textbox(label="Caption for image (Optional)")
|
122 |
|
123 |
iface = gr.Interface(fn=predict,
|
124 |
inputs=[image_input, text_input],
|
125 |
outputs=gr.Label(),
|
126 |
+
examples=[["examples/trump-fake.jpeg", "Donald Trump being arrested by authorities."]])
|
127 |
iface.launch()
|
examples/trump-fake.jpeg
ADDED
models/clip-glide.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3492e0892487a66dfda34e36aa407a2765b6d50bdf72ab50b6543d1541c4982e
|
3 |
+
size 425232242
|
models/clip-ld.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e66b78073bb830105d52dd0040eba2706287c7637a1959363a801c5b2f9d1cc9
|
3 |
+
size 425230745
|
models/clip-sd.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9b062950f01721fd4e947cc0ce1f0a7ae45a45dfbc94d6a0688ca2d0c650d83a
|
3 |
+
size 425230745
|