Yoon-gu Hwang commited on
Commit
b2b4159
·
1 Parent(s): 0d99f19
Files changed (3) hide show
  1. app.py +67 -74
  2. main.py +0 -78
  3. uv.lock +0 -0
app.py CHANGED
@@ -1,78 +1,71 @@
1
  import gradio as gr
2
- import random
3
-
4
-
5
- def pick_plate(color_choice, style_choice):
6
- """Generate a random license plate number based on user preferences."""
7
- # Generate random plate number
8
- letters = ''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ', k=3))
9
- numbers = ''.join(random.choices('0123456789', k=4))
10
-
11
- plate_number = f"{letters}-{numbers}"
12
-
13
- # Create styled output
14
- color_map = {
15
- "Blue": "#1E40AF",
16
- "Green": "#059669",
17
- "Red": "#DC2626",
18
- "Black": "#1F2937"
19
- }
20
-
21
- bg_color = color_map.get(color_choice, "#1E40AF")
22
-
23
- html_output = f"""
24
- <div style="background-color: {bg_color}; color: white; padding: 30px;
25
- border-radius: 10px; text-align: center; font-family: monospace;
26
- font-size: 48px; font-weight: bold; border: 3px solid #FFF;">
27
- {plate_number}
28
- </div>
29
- <p style="text-align: center; margin-top: 20px; font-size: 18px;">
30
- Style: {style_choice} | Color: {color_choice}
31
- </p>
32
- """
33
-
34
- return html_output
35
-
36
-
37
- def create_app():
38
- """Create and configure the Gradio interface."""
39
- with gr.Blocks(title="Plate Picker") as app:
40
- gr.Markdown("# 🚗 Plate Picker")
41
- gr.Markdown("Generate random license plate numbers with custom colors and styles!")
42
-
43
- with gr.Row():
44
- with gr.Column():
45
- color = gr.Radio(
46
- choices=["Blue", "Green", "Red", "Black"],
47
- value="Blue",
48
- label="Plate Color"
49
- )
50
- style = gr.Radio(
51
- choices=["Standard", "Premium", "Classic", "Modern"],
52
- value="Standard",
53
- label="Plate Style"
54
- )
55
- generate_btn = gr.Button("Generate Plate", variant="primary")
56
-
57
- with gr.Column():
58
- output = gr.HTML(label="Your License Plate")
59
-
60
- generate_btn.click(
61
- fn=pick_plate,
62
- inputs=[color, style],
63
- outputs=output
64
- )
65
-
66
- # Generate on page load
67
- app.load(
68
- fn=pick_plate,
69
- inputs=[color, style],
70
- outputs=output
71
- )
72
-
73
- return app
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  if __name__ == "__main__":
77
- app = create_app()
78
- app.launch()
 
1
  import gradio as gr
2
+ import numpy as np
3
+ import pandas as pd
4
+ from datetime import datetime, timedelta
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ def generate_samples(n = 30):
7
+ # 카드 이용 내역 샘플 데이터 생성
8
+ np.random.seed(42)
9
+
10
+ # 날짜 생성 (최근 30일)
11
+ start_date = datetime.now() - timedelta(days=30)
12
+ dates = [start_date + timedelta(days=x) for x in range(n)]
13
+
14
+ # 카드 종류
15
+ cards = ['신한카드', '삼성카드', '현대카드', 'KB국민카드', '우리카드']
16
+
17
+ # 가맹점 종류
18
+ merchants = ['스타벅스', 'GS25', '쿠팡', '네이버페이', '카카오페이',
19
+ '이마트', '올리브영', 'CGV', '배달의민족', '카페베네',
20
+ 'Apple', '11번가', '무신사', '다이소', '맥도날드']
21
+
22
+ # 할부 옵션
23
+ installments = ['일시불', '2개월', '3개월', '6개월', '12개월']
24
+
25
+ # DataFrame 생성
26
+ df = pd.DataFrame({
27
+ '이용일': [d.strftime('%Y-%m-%d') for d in sorted(dates, reverse=True)],
28
+ '이용카드': np.random.choice(cards, n),
29
+ '이용가맹점': np.random.choice(merchants, n),
30
+ '이용금액': np.random.randint(5000, 500000, n),
31
+ })
32
+
33
+ # 할부/회차
34
+ df['할부/회차'] = np.random.choice(installments, n)
35
+
36
+ # 적립/할인율 (0~5%)
37
+ df['적립/할인율(%)'] = np.random.uniform(0.5, 5.0, n).round(2)
38
+
39
+ # 예상적립/할인 = 이용금액 * 적립율
40
+ df['예상적립/할인'] = (df['이용금액'] * df['적립/할인율(%)'] / 100).round(0).astype(int)
41
+
42
+ # 결제원금 = 이용금액 - 예상적립/할인
43
+ df['결제원금'] = df['이용금액'] - df['예상적립/할인']
44
+
45
+ # 결제후잔액 (누적 계산)
46
+ df['결제후잔액'] = df['결제원금'].cumsum()
47
+
48
+ # 수수료(이자) - 할부일 경우만 발생
49
+ df['수수료(이자)'] = 0
50
+ installment_mask = ~df['할부/회차'].isin(['일시불'])
51
+ df.loc[installment_mask, '수수료(이자)'] = np.random.randint(1000, 10000, installment_mask.sum())
52
+ return df
53
+
54
+
55
+ def preprocess_rawdata(file):
56
+ print(file)
57
+ return generate_samples()
58
+
59
+ with gr.Blocks() as demo:
60
+ with gr.Row():
61
+ with gr.Column(scale=1):
62
+ input_files = gr.File(label="Upload Multiple Files Output", file_count="multiple")
63
+ with gr.Column(scale=1):
64
+ a = 1
65
+ with gr.Row():
66
+ df = gr.Dataframe(interactive=True)
67
+
68
+ input_files.upload(preprocess_rawdata, input_files, df)
69
 
70
  if __name__ == "__main__":
71
+ demo.launch()
 
main.py DELETED
@@ -1,78 +0,0 @@
1
- import gradio as gr
2
- import random
3
-
4
-
5
- def pick_plate(color_choice, style_choice):
6
- """Generate a random license plate number based on user preferences."""
7
- # Generate random plate number
8
- letters = ''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ', k=3))
9
- numbers = ''.join(random.choices('0123456789', k=4))
10
-
11
- plate_number = f"{letters}-{numbers}"
12
-
13
- # Create styled output
14
- color_map = {
15
- "Blue": "#1E40AF",
16
- "Green": "#059669",
17
- "Red": "#DC2626",
18
- "Black": "#1F2937"
19
- }
20
-
21
- bg_color = color_map.get(color_choice, "#1E40AF")
22
-
23
- html_output = f"""
24
- <div style="background-color: {bg_color}; color: white; padding: 30px;
25
- border-radius: 10px; text-align: center; font-family: monospace;
26
- font-size: 48px; font-weight: bold; border: 3px solid #FFF;">
27
- {plate_number}
28
- </div>
29
- <p style="text-align: center; margin-top: 20px; font-size: 18px;">
30
- Style: {style_choice} | Color: {color_choice}
31
- </p>
32
- """
33
-
34
- return html_output
35
-
36
-
37
- def create_app():
38
- """Create and configure the Gradio interface."""
39
- with gr.Blocks(title="Plate Picker") as app:
40
- gr.Markdown("# 🚗 Plate Picker")
41
- gr.Markdown("Generate random license plate numbers with custom colors and styles!")
42
-
43
- with gr.Row():
44
- with gr.Column():
45
- color = gr.Radio(
46
- choices=["Blue", "Green", "Red", "Black"],
47
- value="Blue",
48
- label="Plate Color"
49
- )
50
- style = gr.Radio(
51
- choices=["Standard", "Premium", "Classic", "Modern"],
52
- value="Standard",
53
- label="Plate Style"
54
- )
55
- generate_btn = gr.Button("Generate Plate", variant="primary")
56
-
57
- with gr.Column():
58
- output = gr.HTML(label="Your License Plate")
59
-
60
- generate_btn.click(
61
- fn=pick_plate,
62
- inputs=[color, style],
63
- outputs=output
64
- )
65
-
66
- # Generate on page load
67
- app.load(
68
- fn=pick_plate,
69
- inputs=[color, style],
70
- outputs=output
71
- )
72
-
73
- return app
74
-
75
-
76
- if __name__ == "__main__":
77
- app = create_app()
78
- app.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
uv.lock ADDED
The diff for this file is too large to render. See raw diff