ChandraP12330 commited on
Commit
ce6ebb2
1 Parent(s): d341d77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -48,6 +48,7 @@ from langchain_google_genai import ChatGoogleGenerativeAI
48
  from langchain.prompts import PromptTemplate
49
  from google.generativeai.types.safety_types import HarmBlockThreshold, HarmCategory
50
 
 
51
  template="""You are an advanced image captioning AI assistant for surveillance related images.
52
  Your task is to refine and improve an initial image caption using relevant contextual information provided.
53
  You will receive two inputs:
@@ -64,16 +65,6 @@ prompt_template = PromptTemplate(
64
  input_variables=["initial_caption", "context"],
65
  )
66
 
67
- llm = ChatGoogleGenerativeAI(model="gemini-1.5-pro-latest", google_api_key=GOOGLE_API_KEY, temperature=0.2, top_p=1, top_k=1,
68
- safety_settings={
69
- HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
70
- HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
71
- HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
72
- HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
73
-
74
- },
75
- )
76
-
77
 
78
  # Title
79
  st.title("Image Caption Surveillance")
@@ -103,6 +94,15 @@ if image_url:
103
  initial_caption= caption[0]['generated_text']
104
  ##gemini-1.0-pro-latest
105
  ##LLM
 
 
 
 
 
 
 
 
 
106
 
107
  prompt=prompt_template.format(initial_caption=initial_caption, context=context)
108
  response = llm.invoke(prompt)
 
48
  from langchain.prompts import PromptTemplate
49
  from google.generativeai.types.safety_types import HarmBlockThreshold, HarmCategory
50
 
51
+
52
  template="""You are an advanced image captioning AI assistant for surveillance related images.
53
  Your task is to refine and improve an initial image caption using relevant contextual information provided.
54
  You will receive two inputs:
 
65
  input_variables=["initial_caption", "context"],
66
  )
67
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  # Title
70
  st.title("Image Caption Surveillance")
 
94
  initial_caption= caption[0]['generated_text']
95
  ##gemini-1.0-pro-latest
96
  ##LLM
97
+ llm = ChatGoogleGenerativeAI(model="gemini-1.0-pro", google_api_key=GOOGLE_API_KEY, temperature=0.2, top_p=1, top_k=1,
98
+ safety_settings={
99
+ HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
100
+ HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
101
+ HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
102
+ HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
103
+
104
+ },
105
+ )
106
 
107
  prompt=prompt_template.format(initial_caption=initial_caption, context=context)
108
  response = llm.invoke(prompt)