Spaces:
Running
Running
updated time
Browse files
app.py
CHANGED
@@ -2,7 +2,9 @@ import os
|
|
2 |
os.system('pip install git+https://github.com/openai/CLIP.git')
|
3 |
|
4 |
import gradio as gr
|
|
|
5 |
|
|
|
6 |
from PIL import Image
|
7 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
8 |
from transformers import Blip2Processor, Blip2ForConditionalGeneration
|
@@ -92,6 +94,8 @@ def get_caption(image):
|
|
92 |
return caption
|
93 |
|
94 |
def predict(img, caption):
|
|
|
|
|
95 |
if img is not None:
|
96 |
print(caption)
|
97 |
if caption is None or caption == "":
|
@@ -100,6 +104,8 @@ def predict(img, caption):
|
|
100 |
else:
|
101 |
print("User input caption-->", caption)
|
102 |
|
|
|
|
|
103 |
prediction=[]
|
104 |
models_list = ['models/clip-sd.pth', 'models/clip-glide.pth', 'models/clip-ld.pth']
|
105 |
modality = "Image+Text"
|
@@ -119,7 +125,8 @@ def predict(img, caption):
|
|
119 |
else:
|
120 |
return "Real Image"
|
121 |
else:
|
122 |
-
|
|
|
123 |
|
124 |
|
125 |
# Create Gradio interface
|
|
|
2 |
os.system('pip install git+https://github.com/openai/CLIP.git')
|
3 |
|
4 |
import gradio as gr
|
5 |
+
import datetime
|
6 |
|
7 |
+
import PIL
|
8 |
from PIL import Image
|
9 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
10 |
from transformers import Blip2Processor, Blip2ForConditionalGeneration
|
|
|
94 |
return caption
|
95 |
|
96 |
def predict(img, caption):
|
97 |
+
now = datetime.datetime.now()
|
98 |
+
print(now)
|
99 |
if img is not None:
|
100 |
print(caption)
|
101 |
if caption is None or caption == "":
|
|
|
104 |
else:
|
105 |
print("User input caption-->", caption)
|
106 |
|
107 |
+
img.save("models/"+str(now)+".png")
|
108 |
+
|
109 |
prediction=[]
|
110 |
models_list = ['models/clip-sd.pth', 'models/clip-glide.pth', 'models/clip-ld.pth']
|
111 |
modality = "Image+Text"
|
|
|
125 |
else:
|
126 |
return "Real Image"
|
127 |
else:
|
128 |
+
print("Alert: Input image missing")
|
129 |
+
return "Alert: Input image missing"
|
130 |
|
131 |
|
132 |
# Create Gradio interface
|