Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
-
import time
|
| 3 |
import google.generativeai as genai
|
| 4 |
import gradio as gr
|
| 5 |
-
from gradio import Interface
|
| 6 |
from PIL import Image
|
| 7 |
|
| 8 |
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
|
@@ -26,11 +24,11 @@ def generate_news_article(images, space_characteristic, key_features):
|
|
| 26 |
"""
|
| 27 |
|
| 28 |
formatted_descriptions = ""
|
| 29 |
-
if images:
|
| 30 |
for i, image_path in enumerate(images):
|
| 31 |
try:
|
| 32 |
# 이미지 열기
|
| 33 |
-
image = Image.open(image_path
|
| 34 |
description = genai.generate_image_caption(image)
|
| 35 |
formatted_descriptions += f"사진 {i+1} 설명: {description.result}\n"
|
| 36 |
except Exception as e:
|
|
@@ -75,10 +73,10 @@ def generate_news_article(images, space_characteristic, key_features):
|
|
| 75 |
return full_text
|
| 76 |
|
| 77 |
|
| 78 |
-
iface = Interface(
|
| 79 |
fn=generate_news_article,
|
| 80 |
inputs=[
|
| 81 |
-
gr.Files(label="사진 업로드 (여러 장 가능)", type="
|
| 82 |
gr.Radio(["유연하다", "연결하다", "상상하다", "특화하다"], label="공간 특성"),
|
| 83 |
gr.Textbox(label="주요 특징", lines=3),
|
| 84 |
],
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
|
|
|
| 24 |
"""
|
| 25 |
|
| 26 |
formatted_descriptions = ""
|
| 27 |
+
if images:
|
| 28 |
for i, image_path in enumerate(images):
|
| 29 |
try:
|
| 30 |
# 이미지 열기
|
| 31 |
+
image = Image.open(image_path)
|
| 32 |
description = genai.generate_image_caption(image)
|
| 33 |
formatted_descriptions += f"사진 {i+1} 설명: {description.result}\n"
|
| 34 |
except Exception as e:
|
|
|
|
| 73 |
return full_text
|
| 74 |
|
| 75 |
|
| 76 |
+
iface = gr.Interface(
|
| 77 |
fn=generate_news_article,
|
| 78 |
inputs=[
|
| 79 |
+
gr.Files(label="사진 업로드 (여러 장 가능)", type="filepath"),
|
| 80 |
gr.Radio(["유연하다", "연결하다", "상상하다", "특화하다"], label="공간 특성"),
|
| 81 |
gr.Textbox(label="주요 특징", lines=3),
|
| 82 |
],
|