54justin commited on
Commit
101f06b
·
verified ·
1 Parent(s): f3d41f0

Upload 18 files

Browse files
Files changed (7) hide show
  1. .gitignore +36 -0
  2. app.py +13 -23
  3. app_hello.py +7 -0
  4. app_minimal.py +97 -0
  5. requirements.txt +1 -11
  6. requirements_minimal.txt +3 -0
  7. test_simple.py +41 -0
.gitignore ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # �� Copilot �ͦ�
2
+ # Python
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+ *.so
7
+ .Python
8
+ env/
9
+ venv/
10
+ .venv/
11
+ .env
12
+
13
+ # Jupyter Notebook
14
+ .ipynb_checkpoints
15
+
16
+ # Output files
17
+ output/
18
+ *.png
19
+ *.jpg
20
+ *.pdf
21
+ *.html
22
+ *.json
23
+ *.csv
24
+
25
+ # IDE
26
+ .vscode/
27
+ .idea/
28
+ *.swp
29
+ *.swo
30
+
31
+ # OS
32
+ .DS_Store
33
+ Thumbs.db
34
+
35
+ # Logs
36
+ *.log
app.py CHANGED
@@ -1,27 +1,17 @@
1
  # �� Copilot �ͦ�
2
- # 591�����R�� - Hugging Face Spaces����
3
- # �ϥ�Gradio�@���D�n����
4
 
5
- import spaces_config # ���J Spaces �t�m
6
- from gradio_app import create_interface
 
 
 
 
 
 
 
 
 
7
 
8
- # �Ұ�Gradio����
9
  if __name__ == "__main__":
10
- try:
11
- demo = create_interface()
12
- demo.launch()
13
- except Exception as e:
14
- print(f"? �Ұ����Υ���: {e}")
15
- # ���ըϥγ�²�檺�t�m
16
- import gradio as gr
17
-
18
- def simple_interface():
19
- return "? 591���Τ��R�����b��l�ơA�еy��A��..."
20
-
21
- simple_demo = gr.Interface(
22
- fn=simple_interface,
23
- inputs=[],
24
- outputs="text",
25
- title="591�����R��"
26
- )
27
- simple_demo.launch()
 
1
  # �� Copilot �ͦ�
2
+ import gradio as gr
 
3
 
4
+ def hello(name):
5
+ if not name:
6
+ name = "�ϥΪ�"
7
+ return f"Hello {name}! ? 591�����R�����b�}�o��..."
8
+
9
+ demo = gr.Interface(
10
+ fn=hello,
11
+ inputs=gr.Textbox(label="��J�z���W�r", placeholder="�п�J�W�r"),
12
+ outputs=gr.Textbox(label="�ݭ԰T��"),
13
+ title="? 591���Τ��R�� - ���ժ���"
14
+ )
15
 
 
16
  if __name__ == "__main__":
17
+ demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app_hello.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def hello(name):
4
+ return f"Hello {name}! ? 591���Τ��R�����ժ���"
5
+
6
+ demo = gr.Interface(fn=hello, inputs="text", outputs="text")
7
+ demo.launch()
app_minimal.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # �� Copilot �ͦ�
2
+ # �̤p�ƴ��ժ��� - �Ω�E�_ Hugging Face Spaces ���D
3
+
4
+ import gradio as gr
5
+ import pandas as pd
6
+ import numpy as np
7
+ from typing import Dict
8
+
9
+ def create_minimal_test_data():
10
+ """�Ыس̤p���ո��"""
11
+ np.random.seed(42)
12
+
13
+ data = []
14
+ for i in range(20):
15
+ data.append({
16
+ 'title': f'���ժ��� {i+1}',
17
+ 'price': np.random.randint(20000, 40000),
18
+ 'area': np.random.randint(25, 45),
19
+ 'address': f'���������s�ϴ��ո�{i+1}��'
20
+ })
21
+
22
+ return pd.DataFrame(data)
23
+
24
+ def minimal_analysis(sample_size):
25
+ """�̤p�Ƥ��R�\��"""
26
+ try:
27
+ # �Ыش��ո��
28
+ df = create_minimal_test_data()
29
+
30
+ # �򥻲έp
31
+ stats = {
32
+ '�����': len(df),
33
+ '��������': f"{df['price'].mean():.0f} ��",
34
+ '���������': f"{df['price'].median():.0f} ��",
35
+ '�����W��': f"{df['area'].mean():.1f} �W"
36
+ }
37
+
38
+ # �ͦ�²����i
39
+ report = f"""
40
+ # ? 591���Τ��R�� - ���ժ���
41
+
42
+ ## ? �򥻲έp
43
+ - �����`�ơG{stats['�����']} ��
44
+ - ���������G{stats['��������']}
45
+ - ��������ơG{stats['���������']}
46
+ - �����W�ơG{stats['�����W��']}
47
+
48
+ ## ? �t���A
49
+ - ��ƥͦ��G���`
50
+ - ���R�\��G���`
51
+ - Gradio �����G���`
52
+
53
+ **�� Copilot �ͦ�**
54
+ """
55
+
56
+ return report, df.head(10)
57
+
58
+ except Exception as e:
59
+ error_msg = f"""
60
+ # ? ���~���i
61
+
62
+ �o�Ϳ��~�G{str(e)}
63
+
64
+ �o�O�@�ӶE�_�����A�Ц^�������~�T���C
65
+ """
66
+ empty_df = pd.DataFrame()
67
+ return error_msg, empty_df
68
+
69
+ def create_minimal_interface():
70
+ """�Ыس̤p�Ƥ���"""
71
+
72
+ interface = gr.Interface(
73
+ fn=minimal_analysis,
74
+ inputs=[
75
+ gr.Slider(
76
+ minimum=10,
77
+ maximum=50,
78
+ value=20,
79
+ step=10,
80
+ label="���ո�Ƶ���"
81
+ )
82
+ ],
83
+ outputs=[
84
+ gr.Markdown(label="���R���i"),
85
+ gr.Dataframe(label="��ƹw��")
86
+ ],
87
+ title="? 591�����R�� - �E�_����",
88
+ description="�o�O�@�ӳ̤p�ƴ��ժ����A�Ω�E�_ Hugging Face Spaces ���p���D�C",
89
+ theme=gr.themes.Soft(),
90
+ allow_flagging="never"
91
+ )
92
+
93
+ return interface
94
+
95
+ if __name__ == "__main__":
96
+ demo = create_minimal_interface()
97
+ demo.launch()
requirements.txt CHANGED
@@ -1,11 +1 @@
1
- # �� Copilot �ͦ� - Hugging Face Spaces ̤pۮe����
2
- pandas
3
- numpy
4
- matplotlib
5
- seaborn
6
- plotly
7
- requests
8
- beautifulsoup4
9
- transformers
10
- datasets
11
- scikit-learn
 
1
+ # �� Copilot �ͦ� - �Ū� requirementsAϥιw]M��
 
 
 
 
 
 
 
 
 
 
requirements_minimal.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # �� Copilot �ͦ� - �̤p�ƨ̿઩��
2
+ pandas
3
+ numpy
test_simple.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # �� Copilot �ͦ�
2
+ # ²�檺�ɤJ����
3
+
4
+ try:
5
+ import gradio as gr
6
+ print("? Gradio �ɤJ���\")
7
+ except Exception as e:
8
+ print(f"? Gradio �ɤJ����: {e}")
9
+
10
+ try:
11
+ import pandas as pd
12
+ print("? Pandas �ɤJ���\")
13
+ except Exception as e:
14
+ print(f"? Pandas �ɤJ����: {e}")
15
+
16
+ try:
17
+ import numpy as np
18
+ print("? NumPy �ɤJ���\")
19
+ except Exception as e:
20
+ print(f"? NumPy �ɤJ����: {e}")
21
+
22
+ print("? �򥻨̿��ˬd����")
23
+
24
+ # ���հ򥻥\��
25
+ try:
26
+ df = pd.DataFrame({'test': [1, 2, 3]})
27
+ print(f"? DataFrame �Ыئ��\: {len(df)} ��")
28
+ except Exception as e:
29
+ print(f"? DataFrame ���ե���: {e}")
30
+
31
+ try:
32
+ demo = gr.Interface(
33
+ fn=lambda x: f"���տ�J: {x}",
34
+ inputs="text",
35
+ outputs="text"
36
+ )
37
+ print("? Gradio �����Ыئ��\")
38
+ except Exception as e:
39
+ print(f"? Gradio �������ե���: {e}")
40
+
41
+ print("? 591���Τ��R�� - �ɤJ���է���")