Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,43 +1,22 @@
|
|
1 |
-
import
|
2 |
-
from moviepy.editor import ImageSequenceClip
|
3 |
-
import tempfile
|
4 |
import os
|
5 |
-
import shutil # μ΄ λΆλΆμ μΆκ°
|
6 |
|
|
|
|
|
7 |
|
8 |
-
def
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
# μ΄λ―Έμ§ μνμ€λ‘λΆν° λΉλμ€ ν΄λ¦½ μμ± λ° κΈ°ν λ‘μ§...
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
# λΉλμ€ νμΌ μ μ₯
|
27 |
-
output_video_path = os.path.join(temp_dir, "output.mp4")
|
28 |
-
clip.write_videofile(output_video_path, fps=24) # 24fpsλ‘ μΆλ ₯ λΉλμ€ μ μ₯
|
29 |
-
|
30 |
-
# μμ±λ λΉλμ€ νμΌ κ²½λ‘ λ°ν
|
31 |
-
return output_video_path
|
32 |
-
|
33 |
-
return image_paths # μμ λ°νκ°, μ€μ λ‘λ μμ±λ λΉλμ€ νμΌ κ²½λ‘λ₯Ό λ°νν΄μΌ ν¨
|
34 |
-
|
35 |
-
# Gradio μΈν°νμ΄μ€ μ μ
|
36 |
-
with gr.Blocks() as demo:
|
37 |
-
with gr.Row():
|
38 |
-
file_input = gr.File(label="Upload images")
|
39 |
-
|
40 |
-
video_output = gr.Video(label="Output video")
|
41 |
-
file_input.change(images_to_video, inputs=file_input, outputs=video_output)
|
42 |
-
|
43 |
-
demo.launch()
|
|
|
1 |
+
import openai
|
|
|
|
|
2 |
import os
|
|
|
3 |
|
4 |
+
# OpenAI API ν€ μ€μ
|
5 |
+
openai.api_key = os.getenv("OPENAI_API_KEY") # νκ²½ λ³μμμ API ν€λ₯Ό λΆλ¬μ΅λλ€.
|
6 |
|
7 |
+
def generate_keywords_with_gpt(scene_descriptions):
|
8 |
+
responses = []
|
9 |
+
for description in scene_descriptions:
|
10 |
+
response = openai.Completion.create(
|
11 |
+
engine="text-davinci-003", # νΉμ λ€λ₯Έ GPT λͺ¨λΈμ μ νν μ μμ΅λλ€.
|
12 |
+
prompt=f"Generate a representative keyword for the following scene description: {description}",
|
13 |
+
max_tokens=60, # νμν ν ν° μλ₯Ό μ‘°μ ν μ μμ΅λλ€.
|
14 |
+
temperature=0.7
|
15 |
+
)
|
16 |
+
responses.append(response.choices[0].text.strip())
|
17 |
+
return responses
|
|
|
|
|
18 |
|
19 |
+
# μ¬μ© μμ
|
20 |
+
scene_descriptions = ["Enter description for Scene 1", "Enter description for Scene 2"]
|
21 |
+
keywords = generate_keywords_with_gpt(scene_descriptions)
|
22 |
+
print(keywords)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|