Yash911 commited on
Commit
875ef36
1 Parent(s): 5f0d084

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -1,3 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import requests
3
  import cloudinary
@@ -33,21 +45,16 @@ def upload_to_cloudinary(image):
33
  upload_result = cloudinary.uploader.upload(image_data, folder="compvis_app")
34
  return upload_result["secure_url"]
35
 
36
- def get_last_uploaded_images(limit=4):
37
- images = cloudinary.api.resources(type="upload", max_results=limit, prefix="compvis_app/")
38
- return [img["secure_url"] for img in images["resources"]]
39
-
40
  def process_and_upload(image_description):
41
  processed_image = query_model_with_image(image_description)
42
  uploaded_url = upload_to_cloudinary(processed_image)
43
- last_uploaded_images = get_last_uploaded_images()
44
- return processed_image, uploaded_url, last_uploaded_images
45
 
46
  iface = gr.Interface(
47
  fn=process_and_upload,
48
  inputs=gr.inputs.Textbox(label="Image Description"),
49
- outputs=["image", "text", "text"]
50
  )
51
 
52
  if __name__ == "__main__":
53
- iface.launch()
 
1
+ # -*- coding: utf-8 -*-
2
+ """mini_t2i.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1QL7cDE204_CEk2kw87aiM7ArlAVF-1Uu
8
+ """
9
+
10
+ # !pip install gradio
11
+ # !pip install cloudinary
12
+
13
  import gradio as gr
14
  import requests
15
  import cloudinary
 
45
  upload_result = cloudinary.uploader.upload(image_data, folder="compvis_app")
46
  return upload_result["secure_url"]
47
 
 
 
 
 
48
  def process_and_upload(image_description):
49
  processed_image = query_model_with_image(image_description)
50
  uploaded_url = upload_to_cloudinary(processed_image)
51
+ return processed_image, uploaded_url
 
52
 
53
  iface = gr.Interface(
54
  fn=process_and_upload,
55
  inputs=gr.inputs.Textbox(label="Image Description"),
56
+ outputs=["image", "text"]
57
  )
58
 
59
  if __name__ == "__main__":
60
+ iface.launch()