Spaces:
Sleeping
Sleeping
File size: 1,024 Bytes
145ad7d bb2db31 3bd6490 bb2db31 be3c345 bb2db31 be3c345 bb2db31 be3c345 bb2db31 69c569f be3c345 bb2db31 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
import requests
# 구글 이미지 검색 함수
def google_image_search(query):
API_KEY = 'AIzaSyDUz3wkGal0ewRtPlzeMit88bV4hS4ZIVY'
CX = '56b34994f47704ddd'
URL = f"https://www.googleapis.com/customsearch/v1?q={query}&cx={CX}&searchType=image&key={API_KEY}"
response = requests.get(URL)
results = response.json()
image_urls = []
for item in results.get('items', []):
image_url = item['link']
image_urls.append(image_url)
return image_urls
# Gradio 인터페이스 정의
iface = gr.Interface(fn=google_image_search,
inputs=gr.Textbox(lines=2, placeholder="검색할 이미지의 텍스트를 입력하세요..."),
outputs=gr.Image(type="pil", label="검색 결과", tool="editor"),
title="구글 이미지 검색",
description="텍스트를 입력하면 구글 이미지 검색 결과를 보여줍니다.")
# 인터페이스 실행
iface.launch() |