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

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +55 -10
  2. app.py +88 -88
README.md CHANGED
@@ -4,20 +4,65 @@ 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  sdk: gradio
5
  sdk_version: 5.11.0
6
  ---
7
+ # AI Applications Portfolio
8
 
9
+ A collection of interactive AI applications built with Gradio, showcasing various capabilities:
 
 
 
10
 
11
+ ## Applications
12
+
13
+ ### 1. Image Classification
14
+ - Upload and analyze images
15
+ - Get detailed image information
16
+ - View thumbnails and analysis results
17
+
18
+ ### 2. Text Summary
19
+ - Analyze text statistics
20
+ - Generate summaries
21
+ - Support for multiple languages
22
+
23
+ ### 3. Data Visualization
24
+ - Create interactive graphs
25
+ - Visualize numerical data
26
+ - Customizable plotting options
27
+
28
+ ## Tech Stack
29
+ - Python 3.8+
30
+ - Gradio 4.0+
31
+ - Matplotlib 3.7+
32
+ - NumPy 1.24+
33
+ - Pillow 10.0+
34
+
35
+ ## Setup and Installation
36
+
37
+ 1. Clone the repository:
38
+ ```bash
39
+ git clone https://github.com/yourusername/portfolio.git
40
+ cd portfolio
41
+ ```
42
+
43
+ 2. Install dependencies:
44
  ```bash
45
  pip install -r requirements.txt
 
46
  ```
47
 
48
+ 3. Run the application:
 
49
  ```bash
50
+ python app.py
51
+ ```
52
+
53
+ ## Deployment
54
+
55
+ The application is deployed on Hugging Face Spaces:
56
+ [View Live Demo](https://huggingface.co/spaces/shuhayas/AI_Applications_Portfolio)
57
+
58
+ ## Features
59
+ - Modern, responsive UI
60
+ - Interactive applications
61
+ - Real-time processing
62
+ - Cross-platform compatibility
63
+
64
+ ## Contributing
65
+ Feel free to submit issues and enhancement requests!
66
+
67
+ ## License
68
+ MIT License - feel free to use this project for your own portfolio!
app.py CHANGED
@@ -3,7 +3,7 @@ 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;
@@ -56,118 +56,118 @@ custom_css = """
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
 
@@ -177,29 +177,29 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as portfolio:
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
 
@@ -209,43 +209,43 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as portfolio:
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
 
@@ -255,44 +255,44 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as portfolio:
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)
@@ -300,6 +300,6 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as portfolio:
300
  elem_classes="gr-tab-text"
301
  )
302
 
303
- # アプリケーションの起動
304
  if __name__ == "__main__":
305
  portfolio.launch(share=True)
 
3
  import numpy as np
4
  from PIL import Image
5
 
6
+ # Custom CSS
7
  custom_css = """
8
  .container {
9
  max-width: 900px;
 
56
  }
57
  """
58
 
59
+ # Application 1: Image Classification
60
  def image_classification(image):
61
  if image is None:
62
+ return "Please upload an image.", None
63
 
64
+ # Get basic image information
65
  info = f"""
66
+ Image Analysis Results:
67
+ - Size: {image.shape}
68
+ - Color Space: RGB
69
+ - Resolution: {image.shape[0]}x{image.shape[1]} pixels
70
  """
71
 
72
+ # Generate thumbnail
73
  thumbnail = Image.fromarray(image).copy()
74
  thumbnail.thumbnail((200, 200))
75
 
76
  return info, thumbnail
77
 
78
+ # Application 2: Text Summary
79
  def text_summary(text):
80
  if not text:
81
+ return "Please enter text to summarize."
82
 
83
+ # Analyze basic text information
84
  char_count = len(text)
85
  word_count = len(text.split())
86
  line_count = len(text.splitlines())
87
 
88
  summary = f"""
89
+ Text Analysis Results:
90
+ - Character Count: {char_count}
91
+ - Word Count: {word_count}
92
+ - Line Count: {line_count}
93
 
94
+ Summary:
95
  {text[:200] + '...' if len(text) > 200 else text}
96
  """
97
 
98
  return summary
99
 
100
+ # Application 3: Data Visualization
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, "Error: Number of X and Y coordinates must match."
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('Data Visualization', fontsize=16, pad=20)
113
+ plt.xlabel('X Axis', fontsize=12)
114
+ plt.ylabel('Y Axis', fontsize=12)
115
  plt.grid(True, linestyle='--', alpha=0.7)
116
 
117
+ # Improve graph appearance
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, "Graph generated successfully."
123
  except ValueError:
124
+ return None, "Error: Invalid input. Please enter numbers separated by commas."
125
 
126
+ # Build Gradio interface
127
  with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as portfolio:
128
+ # Header
129
  with gr.Column(elem_classes="container"):
130
  gr.Markdown(
131
  """
132
+ # Portfolio Site
133
 
134
+ Welcome to my portfolio site where you can experience various applications I've developed.
135
+ Try out different applications in each tab.
136
  """,
137
  elem_classes="gr-header"
138
  )
139
 
140
+ # Tab container
141
  with gr.Tabs():
142
+ # Image Classification Tab
143
+ with gr.TabItem("📷 Image Classification", elem_classes="gr-tab"):
144
  with gr.Column(elem_classes="gr-box"):
145
  gr.Markdown(
146
  """
147
+ ### Image Classification App
148
+ Upload an image to analyze its features. Higher quality images will yield
149
+ more accurate analysis results.
150
  """,
151
  elem_classes="gr-tab-text"
152
  )
153
  with gr.Row():
154
  with gr.Column():
155
  image_input = gr.Image(
156
+ label="Upload Image",
157
  type="numpy",
158
  elem_classes="gr-input"
159
  )
160
  image_button = gr.Button(
161
+ "Analyze",
162
  elem_classes="gr-button"
163
  )
164
  with gr.Column():
165
  image_output = gr.Textbox(
166
+ label="Analysis Results",
167
  elem_classes="gr-input"
168
  )
169
  image_thumbnail = gr.Image(
170
+ label="Thumbnail",
171
  elem_classes="gr-input"
172
  )
173
 
 
177
  outputs=[image_output, image_thumbnail]
178
  )
179
 
180
+ # Text Summary Tab
181
+ with gr.TabItem("📝 Text Summary", elem_classes="gr-tab"):
182
  with gr.Column(elem_classes="gr-box"):
183
  gr.Markdown(
184
  """
185
+ ### Text Summary App
186
+ Enter text to generate a summary and basic statistics.
187
+ Works with both English and other languages.
188
  """,
189
  elem_classes="gr-tab-text"
190
  )
191
  text_input = gr.Textbox(
192
+ label="Enter Text",
193
+ placeholder="Enter the text you want to summarize...",
194
  lines=5,
195
  elem_classes="gr-input"
196
  )
197
  text_button = gr.Button(
198
+ "Summarize",
199
  elem_classes="gr-button"
200
  )
201
  text_output = gr.Textbox(
202
+ label="Summary Results",
203
  elem_classes="gr-input"
204
  )
205
 
 
209
  outputs=text_output
210
  )
211
 
212
+ # Data Visualization Tab
213
+ with gr.TabItem("📊 Data Visualization", elem_classes="gr-tab"):
214
  with gr.Column(elem_classes="gr-box"):
215
  gr.Markdown(
216
  """
217
+ ### Data Visualization Tool
218
+ Enter X and Y coordinates to generate a beautiful graph.
219
+ Separate numbers with commas.
220
 
221
+ Example:
222
+ - X coordinates: 1, 2, 3, 4, 5
223
+ - Y coordinates: 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 Coordinates",
230
+ placeholder="Example: 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 Coordinates",
236
+ placeholder="Example: 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
+ "Generate Graph",
243
  elem_classes="gr-button"
244
  )
245
  with gr.Row():
246
+ plot_output = gr.Plot(label="Graph")
247
  plot_message = gr.Textbox(
248
+ label="Message",
249
  elem_classes="gr-input"
250
  )
251
 
 
255
  outputs=[plot_output, plot_message]
256
  )
257
 
258
+ # Project Information Tab
259
+ with gr.TabItem("ℹ️ Project Information", elem_classes="gr-tab"):
260
  with gr.Column(elem_classes="gr-box"):
261
  gr.Markdown(
262
  """
263
+ ### About the Project
264
 
265
+ This portfolio site integrates multiple applications built using Python's powerful
266
+ Gradio library.
267
 
268
+ #### Features
269
+ 1. **Image Classification App** 🖼️
270
+ - Upload and analyze images
271
+ - Display basic image information
272
+ - Thumbnail generation
273
 
274
+ 2. **Text Summary App** 📚
275
+ - Basic text statistics
276
+ - Text summarization
277
+ - Multi-language support
278
 
279
+ 3. **Data Visualization Tool** 📈
280
+ - Interactive graph generation
281
+ - Beautiful data visualization
282
+ - Customizable plots
283
 
284
+ #### Tech Stack
285
  - Python 3.8+
286
  - Gradio 4.0+
287
  - Matplotlib 3.7+
288
  - NumPy 1.24+
289
  - Pillow 10.0+
290
 
291
+ #### Source Code
292
+ The source code for this project is available on [GitHub](https://github.com/yourusername/portfolio)
293
 
294
+ #### Contact
295
+ For questions or feedback, please reach out:
296
  - Email: your.email@example.com
297
  - Twitter: @yourusername
298
  - LinkedIn: [Your Name](https://linkedin.com/in/yourprofile)
 
300
  elem_classes="gr-tab-text"
301
  )
302
 
303
+ # Launch application
304
  if __name__ == "__main__":
305
  portfolio.launch(share=True)