seawolf2357 commited on
Commit
f7f4bea
·
verified ·
1 Parent(s): 25abb2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -39
app.py CHANGED
@@ -1,44 +1,40 @@
1
  import gradio as gr
2
- import imageio
3
- import numpy as np
4
- from PIL import Image
5
 
6
- def resize_image(image, target_width, target_height):
7
- """
8
- 이미지를 지정된 크기로 조정합니다.
9
- """
10
- image_pil = Image.fromarray(image).resize((target_width, target_height), Image.ANTIALIAS)
11
- return np.array(image_pil)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- def create_video(images):
14
- """
15
- 주어진 이미지 리스트로부터 비디오를 생성합니다.
16
- 모든 이미지는 비디오에 추가되기 전에 동일한 크기로 조정됩니다.
17
- """
18
- target_width = 1920
19
- target_height = 1080
20
- with imageio.get_writer('output_video.mp4', fps=2) as video:
21
- for img in images:
22
- img_resized = resize_image(img, target_width, target_height)
23
- video.append_data(img_resized)
24
- return 'output_video.mp4'
25
-
26
- def process_images(image_files):
27
- """
28
- 업로드된 이미지 파일들을 처리하여 비디오를 생성합니다.
29
- """
30
- images = [imageio.v3.imread(image_file) for image_file in image_files]
31
- video_file = create_video(images)
32
- return video_file
33
-
34
- # Gradio 인터페이스 정의
35
- iface = gr.Interface(
36
- fn=process_images,
37
- inputs=gr.File(label="Upload Images", type="file", multiple_files=True), # 수정된 부분
38
- outputs="file",
39
- title="Image to Video Converter",
40
- description="Upload multiple images to create a video."
41
- )
42
 
43
  # Gradio 앱 실행
44
- iface.launch()
 
1
  import gradio as gr
2
+ import requests
 
 
3
 
4
+ def get_lunar_info(year, month, day, time):
5
+ # API URL 설정
6
+ url = "https://api.example.com/get_lunar_info"
7
+
8
+ # API에 전달할 데이터 설정
9
+ data = {
10
+ "year": year,
11
+ "month": month,
12
+ "day": day,
13
+ "time": time
14
+ }
15
+
16
+ # API 호출
17
+ response = requests.post(url, json=data)
18
+
19
+ # API 응답 확인 및 결과 반환
20
+ if response.status_code == 200:
21
+ return response.json()
22
+ else:
23
+ return "API 호출에 실패했습니다."
24
 
25
+ # Gradio 인터페이스 구성
26
+ with gr.Blocks() as demo:
27
+ gr.Markdown("### 생년월일 생시 정보 입력")
28
+ year = gr.Textbox(label="생년(예: 1990)")
29
+ month = gr.Textbox(label="생월(예: 01)")
30
+ day = gr.Textbox(label="생일(예: 31)")
31
+ time = gr.Textbox(label="생시(예시: 1030)")
32
+
33
+ submit_button = gr.Button("정보 제출")
34
+
35
+ result = gr.Textbox(label="결과")
36
+
37
+ submit_button.click(fn=get_lunar_info, inputs=[year, month, day, time], outputs=result)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  # Gradio 앱 실행
40
+ demo.launch()