FengHou97 commited on
Commit
87741c9
·
verified ·
1 Parent(s): 86c56d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -14
app.py CHANGED
@@ -7,17 +7,6 @@ from dotenv import load_dotenv
7
  import google.generativeai as genai
8
  import os
9
 
10
- # from openai import OpenAI
11
- # client = OpenAI(api_key="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")
12
- # import base64
13
-
14
- # # Open the image file and encode it as a base64 string
15
- # def encode_image(image_path):
16
- # with open(image_path, "rb") as image_file:
17
- # return base64.b64encode(image_file.read()).decode("utf-8")
18
-
19
- #load_dotenv()
20
- #GOOGLE_API_KEY = os.getenv("AIzaSyByqW3ByYPxC4xLS_NhgwAOAMMEgB7DvoY")
21
  genai.configure(api_key="AIzaSyByqW3ByYPxC4xLS_NhgwAOAMMEgB7DvoY")
22
  model_vision = genai.GenerativeModel('gemini-1.5-flash')
23
 
@@ -59,7 +48,6 @@ inputs = [
59
  gr.Textbox(lines=1,
60
  label="Prior Domains", placeholder="Add a domain label, one by one"),
61
  ]
62
- images="festival.jpg"
63
 
64
  def shot(image, labels_text, model_name, hypothesis_template_prefix, hypothesis_template_suffix, domains_text):
65
  labels = [label.strip(" ") for label in labels_text.strip(" ").split(",")]
@@ -87,13 +75,12 @@ iface = gr.Interface(shot,
87
  inputs,
88
  "label",
89
  examples=[
90
- #["festival.jpg", "lantern, firecracker, couplet", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", "clear, autumn, day, side, partial occlusion"],
91
  ["car_occlusion.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", ""],
92
  ["foggy_motor.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", ""],
93
  ["night_truck.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", "clear, autumn, night, side, no occlusion"],
94
  ["rainy_front_truck.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", ""],
95
  ["truck_top.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", "clear, summer, day, top, no occlusion"],],
96
- description="""<p> <br><br>
97
  Paper: <a href='https://arxiv.org/pdf/2403.02714'>https://arxiv.org/pdf/2403.02714</a> <br>
98
  To begin with the demo, provide a picture (either upload manually, or select from the given examples) and add class labels one by one. Optionally, you can also add template as a prefix to the class labels. <br>""",
99
  title="Cross-Domain Recognition")
 
7
  import google.generativeai as genai
8
  import os
9
 
 
 
 
 
 
 
 
 
 
 
 
10
  genai.configure(api_key="AIzaSyByqW3ByYPxC4xLS_NhgwAOAMMEgB7DvoY")
11
  model_vision = genai.GenerativeModel('gemini-1.5-flash')
12
 
 
48
  gr.Textbox(lines=1,
49
  label="Prior Domains", placeholder="Add a domain label, one by one"),
50
  ]
 
51
 
52
  def shot(image, labels_text, model_name, hypothesis_template_prefix, hypothesis_template_suffix, domains_text):
53
  labels = [label.strip(" ") for label in labels_text.strip(" ").split(",")]
 
75
  inputs,
76
  "label",
77
  examples=[
 
78
  ["car_occlusion.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", ""],
79
  ["foggy_motor.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", ""],
80
  ["night_truck.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", "clear, autumn, night, side, no occlusion"],
81
  ["rainy_front_truck.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", ""],
82
  ["truck_top.png", "car, bus, truck", "ViT/B-16", "a photo of a {}", "in {} {} {} from {} with {}.", "clear, summer, day, top, no occlusion"],],
83
+ description="""<p> Demo for Domain CLIP, an algorithm for Training-Free Adaptive Domain Generalization. For more information about our project, refer to our paper.<br><br>
84
  Paper: <a href='https://arxiv.org/pdf/2403.02714'>https://arxiv.org/pdf/2403.02714</a> <br>
85
  To begin with the demo, provide a picture (either upload manually, or select from the given examples) and add class labels one by one. Optionally, you can also add template as a prefix to the class labels. <br>""",
86
  title="Cross-Domain Recognition")