Spaces:
Build error
Build error
Update tasks/ref_in_gpt3.py
Browse files- tasks/ref_in_gpt3.py +23 -8
tasks/ref_in_gpt3.py
CHANGED
@@ -39,19 +39,34 @@ prompts.append("change the red apple to a green one, task: (referring editing),
|
|
39 |
prompts.append("replace the dog with a cat, task: (referring editing), source: [dot], target: <cat>;")
|
40 |
prompts.append("replace the red apple with a green one, task: (referring editing), source: [red apple], target: <green apple>;")
|
41 |
|
|
|
|
|
|
|
42 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
43 |
|
44 |
def get_gpt3_response(prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
response = openai.Completion.create(
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
)
|
54 |
-
|
55 |
return response
|
56 |
|
57 |
def referring_inpainting_gpt3(model, image, instruction, *args, **kwargs):
|
|
|
39 |
prompts.append("replace the dog with a cat, task: (referring editing), source: [dot], target: <cat>;")
|
40 |
prompts.append("replace the red apple with a green one, task: (referring editing), source: [red apple], target: <green apple>;")
|
41 |
|
42 |
+
openai.api_type = "azure"
|
43 |
+
openai.api_base = "https://xdecoder.openai.azure.com/"
|
44 |
+
openai.api_version = "2022-12-01"
|
45 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
46 |
|
47 |
def get_gpt3_response(prompt):
|
48 |
+
# response = openai.Completion.create(
|
49 |
+
# model="text-davinci-003",
|
50 |
+
# prompt=prompt,
|
51 |
+
# temperature=0.7,
|
52 |
+
# max_tokens=128,
|
53 |
+
# top_p=1,
|
54 |
+
# frequency_penalty=0,
|
55 |
+
# presence_penalty=0
|
56 |
+
# )
|
57 |
+
|
58 |
response = openai.Completion.create(
|
59 |
+
engine="text001",
|
60 |
+
prompt=prompt,
|
61 |
+
temperature=1,
|
62 |
+
max_tokens=100,
|
63 |
+
top_p=0.5,
|
64 |
+
frequency_penalty=0,
|
65 |
+
presence_penalty=0,
|
66 |
+
best_of=1,
|
67 |
+
stop=None
|
68 |
)
|
69 |
+
|
70 |
return response
|
71 |
|
72 |
def referring_inpainting_gpt3(model, image, instruction, *args, **kwargs):
|