shuhayas commited on
Commit
606280e
·
verified ·
1 Parent(s): 35db3da

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. .gitignore +6 -0
  2. .gradio/certificate.pem +31 -0
  3. README.md +19 -8
  4. app.py +305 -0
  5. requirements.txt +4 -0
.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ venv/
5
+ .env
6
+ .DS_Store
.gradio/certificate.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
3
+ TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
4
+ cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
5
+ WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
6
+ ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
7
+ MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
8
+ h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
9
+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
10
+ A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
11
+ T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
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1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
28
+ 4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
29
+ mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
30
+ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
31
+ -----END CERTIFICATE-----
README.md CHANGED
@@ -1,12 +1,23 @@
1
  ---
2
- title: AI Applications Portfolio
3
- emoji: 🐨
4
- colorFrom: gray
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.12.0
8
  app_file: app.py
9
- pinned: false
 
10
  ---
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
1
  ---
2
+ title: AI_Applications_Portfolio
 
 
 
 
 
3
  app_file: app.py
4
+ sdk: gradio
5
+ sdk_version: 5.11.0
6
  ---
7
+ # Portfolio Applications
8
+
9
+ This is a collection of interactive applications built with Gradio, including:
10
+ - Image Classification
11
+ - Text Summarization
12
+ - Data Visualization
13
+
14
+ ## Setup
15
+ ```bash
16
+ pip install -r requirements.txt
17
+ python app.py
18
+ ```
19
 
20
+ ## Deploy
21
+ To deploy to Hugging Face Spaces:
22
+ ```bash
23
+ gradio deploy
app.py ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ # カスタムCSS
7
+ custom_css = """
8
+ .container {
9
+ max-width: 900px;
10
+ margin: auto;
11
+ padding: 20px;
12
+ }
13
+ .gr-header {
14
+ text-align: center;
15
+ margin-bottom: 40px;
16
+ }
17
+ .gr-header h1 {
18
+ color: #2a2a2a;
19
+ font-size: 2.5em;
20
+ margin-bottom: 10px;
21
+ }
22
+ .gr-header p {
23
+ color: #666;
24
+ font-size: 1.2em;
25
+ }
26
+ .gr-tab-text {
27
+ font-size: 1.1em;
28
+ line-height: 1.6;
29
+ }
30
+ .gr-button {
31
+ background-color: #2e7af5 !important;
32
+ color: white !important;
33
+ border: none !important;
34
+ border-radius: 8px !important;
35
+ padding: 10px 20px !important;
36
+ transition: all 0.3s ease !important;
37
+ }
38
+ .gr-button:hover {
39
+ background-color: #1c5ed9 !important;
40
+ transform: translateY(-2px);
41
+ }
42
+ .gr-input {
43
+ border-radius: 8px !important;
44
+ border: 2px solid #e0e0e0 !important;
45
+ padding: 12px !important;
46
+ }
47
+ .gr-input:focus {
48
+ border-color: #2e7af5 !important;
49
+ box-shadow: 0 0 0 2px rgba(46,122,245,0.2) !important;
50
+ }
51
+ .gr-box {
52
+ border-radius: 12px !important;
53
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
54
+ padding: 20px !important;
55
+ background: white !important;
56
+ }
57
+ """
58
+
59
+ # アプリケーション1:画像分類
60
+ def image_classification(image):
61
+ if image is None:
62
+ return "画像をアップロードしてください。", None
63
+
64
+ # 画像の基本情報を取得
65
+ info = f"""
66
+ 画像分析結果:
67
+ - サイズ: {image.shape}
68
+ - 色空間: RGB
69
+ - 解像度: {image.shape[0]}x{image.shape[1]}ピクセル
70
+ """
71
+
72
+ # サムネイル画像を生成
73
+ thumbnail = Image.fromarray(image).copy()
74
+ thumbnail.thumbnail((200, 200))
75
+
76
+ return info, thumbnail
77
+
78
+ # アプリケーション2:テキスト要約
79
+ def text_summary(text):
80
+ if not text:
81
+ return "テキストを入力してください。"
82
+
83
+ # 文章の基本情報を分析
84
+ char_count = len(text)
85
+ word_count = len(text.split())
86
+ line_count = len(text.splitlines())
87
+
88
+ summary = f"""
89
+ テキスト分析結果:
90
+ - 文字数: {char_count}文字
91
+ - 単語数: {word_count}語
92
+ - 行数: {line_count}行
93
+
94
+ 要約:
95
+ {text[:200] + '...' if len(text) > 200 else text}
96
+ """
97
+
98
+ return summary
99
+
100
+ # アプリケーション3:データ可視化
101
+ def visualize_data(x_input, y_input):
102
+ try:
103
+ x = [float(i.strip()) for i in x_input.split(',')]
104
+ y = [float(i.strip()) for i in y_input.split(',')]
105
+
106
+ if len(x) != len(y):
107
+ return None, "エラー: X座標とY座標の数が一致しません。"
108
+
109
+ fig = plt.figure(figsize=(10, 6))
110
+ plt.style.use('seaborn')
111
+ plt.plot(x, y, 'o-', linewidth=2, markersize=8, color='#2e7af5')
112
+ plt.title('データ可視化', fontsize=16, pad=20)
113
+ plt.xlabel('X軸', fontsize=12)
114
+ plt.ylabel('Y軸', fontsize=12)
115
+ plt.grid(True, linestyle='--', alpha=0.7)
116
+
117
+ # グラフの見た目を改善
118
+ plt.tick_params(axis='both', which='major', labelsize=10)
119
+ plt.gca().spines['top'].set_visible(False)
120
+ plt.gca().spines['right'].set_visible(False)
121
+
122
+ return fig, "グラフが生成されました。"
123
+ except ValueError:
124
+ return None, "エラー: 無効な入力です。数値をカンマで区切って入力してください。"
125
+
126
+ # Gradioインターフェースの構築
127
+ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as portfolio:
128
+ # ヘッダー
129
+ with gr.Column(elem_classes="container"):
130
+ gr.Markdown(
131
+ """
132
+ # ポートフォリオサイト
133
+
134
+ 私が開発したさまざまなアプリケーションを体験できるポートフォリオサイトへようこそ。
135
+ 各タブで異なるアプリケーションを試すことができます。
136
+ """,
137
+ elem_classes="gr-header"
138
+ )
139
+
140
+ # タブコンテナ
141
+ with gr.Tabs():
142
+ # 画像分類タブ
143
+ with gr.TabItem("📷 画像分類", elem_classes="gr-tab"):
144
+ with gr.Column(elem_classes="gr-box"):
145
+ gr.Markdown(
146
+ """
147
+ ### 画像分類アプリ
148
+ 画像をアップロードすると、その特徴を分析します。高品質な画像をアップロードすることで、
149
+ より正確な分析結果が得られます。
150
+ """,
151
+ elem_classes="gr-tab-text"
152
+ )
153
+ with gr.Row():
154
+ with gr.Column():
155
+ image_input = gr.Image(
156
+ label="画像をアップロード",
157
+ type="numpy",
158
+ elem_classes="gr-input"
159
+ )
160
+ image_button = gr.Button(
161
+ "分析開始",
162
+ elem_classes="gr-button"
163
+ )
164
+ with gr.Column():
165
+ image_output = gr.Textbox(
166
+ label="分析結果",
167
+ elem_classes="gr-input"
168
+ )
169
+ image_thumbnail = gr.Image(
170
+ label="サムネイル",
171
+ elem_classes="gr-input"
172
+ )
173
+
174
+ image_button.click(
175
+ image_classification,
176
+ inputs=image_input,
177
+ outputs=[image_output, image_thumbnail]
178
+ )
179
+
180
+ # テキスト要約タブ
181
+ with gr.TabItem("📝 テキスト要約", elem_classes="gr-tab"):
182
+ with gr.Column(elem_classes="gr-box"):
183
+ gr.Markdown(
184
+ """
185
+ ### テキスト要約アプリ
186
+ 長い文章を入力すると、要約と基本的な統計情報を生成します。
187
+ 日本語、英語どちらの入力にも対応しています。
188
+ """,
189
+ elem_classes="gr-tab-text"
190
+ )
191
+ text_input = gr.Textbox(
192
+ label="テキストを入力",
193
+ placeholder="ここに要約したいテキストを入力してください...",
194
+ lines=5,
195
+ elem_classes="gr-input"
196
+ )
197
+ text_button = gr.Button(
198
+ "要約開始",
199
+ elem_classes="gr-button"
200
+ )
201
+ text_output = gr.Textbox(
202
+ label="要約結果",
203
+ elem_classes="gr-input"
204
+ )
205
+
206
+ text_button.click(
207
+ text_summary,
208
+ inputs=text_input,
209
+ outputs=text_output
210
+ )
211
+
212
+ # データ可視化タブ
213
+ with gr.TabItem("📊 データ可視化", elem_classes="gr-tab"):
214
+ with gr.Column(elem_classes="gr-box"):
215
+ gr.Markdown(
216
+ """
217
+ ### データ可視化ツール
218
+ X座標とY座標を入力すると、美しいグラフを生成します。
219
+ 数値はカンマで区切って入力してください。
220
+
221
+ 例:
222
+ - X座標: 1, 2, 3, 4, 5
223
+ - Y座標: 10, 20, 15, 25, 30
224
+ """,
225
+ elem_classes="gr-tab-text"
226
+ )
227
+ with gr.Row():
228
+ x_input = gr.Textbox(
229
+ label="X座標",
230
+ placeholder="例: 1, 2, 3, 4, 5",
231
+ value="1, 2, 3, 4, 5",
232
+ elem_classes="gr-input"
233
+ )
234
+ y_input = gr.Textbox(
235
+ label="Y座標",
236
+ placeholder="例: 10, 20, 30, 40, 50",
237
+ value="10, 20, 30, 40, 50",
238
+ elem_classes="gr-input"
239
+ )
240
+
241
+ plot_button = gr.Button(
242
+ "グラフ生成",
243
+ elem_classes="gr-button"
244
+ )
245
+ with gr.Row():
246
+ plot_output = gr.Plot(label="グラフ")
247
+ plot_message = gr.Textbox(
248
+ label="メッセージ",
249
+ elem_classes="gr-input"
250
+ )
251
+
252
+ plot_button.click(
253
+ visualize_data,
254
+ inputs=[x_input, y_input],
255
+ outputs=[plot_output, plot_message]
256
+ )
257
+
258
+ # プロジェクト情報タブ
259
+ with gr.TabItem("ℹ️ プロジェクト情報", elem_classes="gr-tab"):
260
+ with gr.Column(elem_classes="gr-box"):
261
+ gr.Markdown(
262
+ """
263
+ ### プロジェクトについて
264
+
265
+ このポートフォリオサイトは、Pythonの強力なライブラリGradioを使用して作成された
266
+ 複数のアプリケーションを統合したものです。
267
+
268
+ #### 機能一覧
269
+ 1. **画像分類アプリ** 🖼️
270
+ - 画像をアップロードして分析
271
+ - 画像の基本情報を表示
272
+ - サムネイル生成機能
273
+
274
+ 2. **テキスト要約アプリ** 📚
275
+ - テキストの基本統計情報
276
+ - 文章の要約機能
277
+ - 日本語・英語対応
278
+
279
+ 3. **データ可視化ツール** 📈
280
+ - インタラクティブなグラフ生成
281
+ - 美しいデータ可視化
282
+ - カスタマイズ可能なプロット
283
+
284
+ #### 技術スタック
285
+ - Python 3.8+
286
+ - Gradio 4.0+
287
+ - Matplotlib 3.7+
288
+ - NumPy 1.24+
289
+ - Pillow 10.0+
290
+
291
+ #### ソースコード
292
+ このプロジェクトのソースコードは[GitHub](https://github.com/yourusername/portfolio)で公開されています。
293
+
294
+ #### 連絡先
295
+ 質問やフィードバックがありましたら、以下の連絡先までお願いします:
296
+ - Email: your.email@example.com
297
+ - Twitter: @yourusername
298
+ - LinkedIn: [Your Name](https://linkedin.com/in/yourprofile)
299
+ """,
300
+ elem_classes="gr-tab-text"
301
+ )
302
+
303
+ # アプリケーションの起動
304
+ if __name__ == "__main__":
305
+ portfolio.launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio>=4.0.0
2
+ matplotlib>=3.7.0
3
+ numpy>=1.24.0
4
+ Pillow>=10.0.0