Spaces:
Runtime error
Runtime error
LanHarmony
commited on
Commit
•
3cf1439
1
Parent(s):
fa02329
introduce control net from diffusers
Browse files
app.py
CHANGED
@@ -70,27 +70,27 @@ def cut_dialogue_history(history_memory, keep_last_n_words=500):
|
|
70 |
class ConversationBot:
|
71 |
def __init__(self):
|
72 |
print("Initializing VisualChatGPT")
|
73 |
-
self.llm = OpenAI(temperature=0, openai_api_key="sk-
|
74 |
self.edit = ImageEditing(device="cuda:0")
|
75 |
self.i2t = ImageCaptioning(device="cuda:0")
|
76 |
self.t2i = T2I(device="cuda:0")
|
77 |
self.image2canny = image2canny_new()
|
78 |
self.canny2image = canny2image_new(device="cuda:0")
|
79 |
-
self.image2line = image2line_new()
|
80 |
-
self.line2image = line2image_new(device="cuda:0")
|
81 |
-
self.image2hed = image2hed_new()
|
82 |
-
self.hed2image = hed2image_new(device="cuda:0")
|
83 |
-
self.image2scribble = image2scribble_new()
|
84 |
-
self.scribble2image = scribble2image_new(device="cuda:0")
|
85 |
-
self.image2pose = image2pose_new()
|
86 |
-
self.pose2image = pose2image_new(device="cuda:0")
|
87 |
self.BLIPVQA = BLIPVQA(device="cuda:0")
|
88 |
-
self.image2seg = image2seg_new()
|
89 |
-
self.seg2image = seg2image_new(device="cuda:0")
|
90 |
-
self.image2depth = image2depth_new()
|
91 |
-
self.depth2image = depth2image_new(device="cuda:0")
|
92 |
-
self.image2normal = image2normal_new()
|
93 |
-
self.normal2image = normal2image_new(device="cuda:0")
|
94 |
self.pix2pix = Pix2Pix(device="cuda:0")
|
95 |
self.memory = ConversationBufferMemory(memory_key="chat_history", output_key='output')
|
96 |
self.tools = [
|
@@ -106,19 +106,18 @@ class ConversationBot:
|
|
106 |
Tool(name="Replace Something From The Photo", func=self.edit.replace_part_of_image,
|
107 |
description="useful for when you want to replace an object from the object description or location with another object from its description. "
|
108 |
"The input to this tool should be a comma seperated string of three, representing the image_path, the object to be replaced, the object to be replaced with "),
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
# "The input to this tool should be a comma seperated string of two, representing the image_path and the user description. "),
|
122 |
# Tool(name="Line Detection On Image", func=self.image2line.inference,
|
123 |
# description="useful for when you want to detect the straight line of the image. like: detect the straight lines of this image, or straight line detection on image, or peform straight line detection on this image, or detect the straight line image of this image. "
|
124 |
# "The input to this tool should be a string, representing the image_path"),
|
|
|
70 |
class ConversationBot:
|
71 |
def __init__(self):
|
72 |
print("Initializing VisualChatGPT")
|
73 |
+
self.llm = OpenAI(temperature=0, openai_api_key="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")
|
74 |
self.edit = ImageEditing(device="cuda:0")
|
75 |
self.i2t = ImageCaptioning(device="cuda:0")
|
76 |
self.t2i = T2I(device="cuda:0")
|
77 |
self.image2canny = image2canny_new()
|
78 |
self.canny2image = canny2image_new(device="cuda:0")
|
79 |
+
# self.image2line = image2line_new()
|
80 |
+
# self.line2image = line2image_new(device="cuda:0")
|
81 |
+
# self.image2hed = image2hed_new()
|
82 |
+
# self.hed2image = hed2image_new(device="cuda:0")
|
83 |
+
# self.image2scribble = image2scribble_new()
|
84 |
+
# self.scribble2image = scribble2image_new(device="cuda:0")
|
85 |
+
# self.image2pose = image2pose_new()
|
86 |
+
# self.pose2image = pose2image_new(device="cuda:0")
|
87 |
self.BLIPVQA = BLIPVQA(device="cuda:0")
|
88 |
+
# self.image2seg = image2seg_new()
|
89 |
+
# self.seg2image = seg2image_new(device="cuda:0")
|
90 |
+
# self.image2depth = image2depth_new()
|
91 |
+
# self.depth2image = depth2image_new(device="cuda:0")
|
92 |
+
# self.image2normal = image2normal_new()
|
93 |
+
# self.normal2image = normal2image_new(device="cuda:0")
|
94 |
self.pix2pix = Pix2Pix(device="cuda:0")
|
95 |
self.memory = ConversationBufferMemory(memory_key="chat_history", output_key='output')
|
96 |
self.tools = [
|
|
|
106 |
Tool(name="Replace Something From The Photo", func=self.edit.replace_part_of_image,
|
107 |
description="useful for when you want to replace an object from the object description or location with another object from its description. "
|
108 |
"The input to this tool should be a comma seperated string of three, representing the image_path, the object to be replaced, the object to be replaced with "),
|
109 |
+
Tool(name="Instruct Image Using Text", func=self.pix2pix.inference,
|
110 |
+
description="useful for when you want to the style of the image to be like the text. like: make it look like a painting. or make it like a robot. "
|
111 |
+
"The input to this tool should be a comma seperated string of two, representing the image_path and the text. "),
|
112 |
+
Tool(name="Answer Question About The Image", func=self.BLIPVQA.get_answer_from_question_and_image,
|
113 |
+
description="useful for when you need an answer for a question based on an image. like: what is the background color of the last image, how many cats in this figure, what is in this figure. "
|
114 |
+
"The input to this tool should be a comma seperated string of two, representing the image_path and the question"),
|
115 |
+
Tool(name="Edge Detection On Image", func=self.image2canny.inference,
|
116 |
+
description="useful for when you want to detect the edge of the image. like: detect the edges of this image, or canny detection on image, or peform edge detection on this image, or detect the canny image of this image. "
|
117 |
+
"The input to this tool should be a string, representing the image_path"),
|
118 |
+
Tool(name="Generate Image Condition On Canny Image", func=self.canny2image.inference,
|
119 |
+
description="useful for when you want to generate a new real image from both the user desciption and a canny image. like: generate a real image of a object or something from this canny image, or generate a new real image of a object or something from this edge image. "
|
120 |
+
"The input to this tool should be a comma seperated string of two, representing the image_path and the user description. "),
|
|
|
121 |
# Tool(name="Line Detection On Image", func=self.image2line.inference,
|
122 |
# description="useful for when you want to detect the straight line of the image. like: detect the straight lines of this image, or straight line detection on image, or peform straight line detection on this image, or detect the straight line image of this image. "
|
123 |
# "The input to this tool should be a string, representing the image_path"),
|