Harsh502s commited on
Commit
0fc7dee
·
1 Parent(s): 59a03b2
Files changed (2) hide show
  1. Pages/Recommender App.py +276 -79
  2. app.py +4 -21
Pages/Recommender App.py CHANGED
@@ -88,154 +88,350 @@ def recommend(anime, genre=None):
88
 
89
  # Function to display the top 8 animes with the highest rating
90
  def top_animes():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  top8 = anime_data.sort_values("score", ascending=False).head(8)
92
 
93
  with st.container():
94
- col1, col2, col3, col4 = st.columns(4)
95
- with col1:
96
- st.write(f"[{top8.iloc[0].title}]({top8.iloc[0].anime_url})")
 
 
 
 
97
  st.image(top8.iloc[0].poster)
98
- with col2:
99
- st.write(f"[{top8.iloc[1].title}]({top8.iloc[1].anime_url})")
 
 
 
 
100
  st.image(top8.iloc[1].poster)
101
- with col3:
102
- st.write(f"[{top8.iloc[2].title}]({top8.iloc[2].anime_url})")
 
 
 
 
103
  st.image(top8.iloc[2].poster)
104
- with col4:
105
- st.write(f"[{top8.iloc[3].title}]({top8.iloc[3].anime_url})")
 
 
 
 
106
  st.image(top8.iloc[3].poster)
107
 
108
  st.divider()
109
 
110
  with st.container():
111
- col5, col6, col7, col8 = st.columns(4)
112
- with col5:
113
- st.write(f"[{top8.iloc[4].title}]({top8.iloc[4].anime_url})")
 
 
 
 
114
  st.image(top8.iloc[4].poster)
115
- with col6:
116
- st.write(f"[{top8.iloc[5].title}]({top8.iloc[5].anime_url})")
 
 
 
 
117
  st.image(top8.iloc[5].poster)
118
- with col7:
119
- st.write(f"[{top8.iloc[6].title}]({top8.iloc[6].anime_url})")
 
 
 
 
120
  st.image(top8.iloc[6].poster)
121
- with col8:
122
- st.write(f"[{top8.iloc[7].title}]({top8.iloc[7].anime_url})")
 
 
 
 
123
  st.image(top8.iloc[7].poster)
124
 
125
 
126
  # Function to display the top 8 animes for user given genre
127
  def top_animes_genres(genre_select):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  top_8_genre = anime_data[
129
  anime_data["genres"].str.contains(genre_select)
130
  ].sort_values("score", ascending=False)[:8]
131
- col1, col2, col3, col4 = st.columns(4)
132
- with col1:
133
- st.write(f"[{top_8_genre.iloc[0].title}]({top_8_genre.iloc[0].anime_url})")
 
 
 
 
134
  st.image(top_8_genre.iloc[0].poster)
135
- with col2:
136
- st.write(f"[{top_8_genre.iloc[1].title}]({top_8_genre.iloc[1].anime_url})")
 
 
 
 
137
  st.image(top_8_genre.iloc[1].poster)
138
- with col3:
139
- st.write(f"[{top_8_genre.iloc[2].title}]({top_8_genre.iloc[2].anime_url})")
 
 
 
 
140
  st.image(top_8_genre.iloc[2].poster)
141
- with col4:
142
- st.write(f"[{top_8_genre.iloc[3].title}]({top_8_genre.iloc[3].anime_url})")
 
 
 
 
143
  st.image(top_8_genre.iloc[3].poster)
144
 
145
  st.divider()
146
 
147
- col5, col6, col7, col8 = st.columns(4)
148
- with col5:
149
- st.write(f"[{top_8_genre.iloc[4].title}]({top_8_genre.iloc[4].anime_url})")
 
 
 
 
150
  st.image(top_8_genre.iloc[4].poster)
151
- with col6:
152
- st.write(f"[{top_8_genre.iloc[5].title}]({top_8_genre.iloc[5].anime_url})")
 
 
 
 
153
  st.image(top_8_genre.iloc[5].poster)
154
- with col7:
155
- st.write(f"[{top_8_genre.iloc[6].title}]({top_8_genre.iloc[6].anime_url})")
 
 
 
 
156
  st.image(top_8_genre.iloc[6].poster)
157
- with col8:
158
- st.write(f"[{top_8_genre.iloc[7].title}]({top_8_genre.iloc[7].anime_url})")
 
 
 
 
159
  st.image(top_8_genre.iloc[7].poster)
160
 
161
 
162
  # Function to display the top 8 animes with user given anime name for all genres
163
  def top_animes_custom(anime_select):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  (
165
  recommended_anime_names,
166
  recommended_anime_posters,
167
  recommended_anime_urls,
168
  ) = recommend(anime_select)
169
  with st.container():
170
- col1, col2, col3, col4 = st.columns(4)
171
- with col1:
172
- st.write(f"[{recommended_anime_names[0]}]({recommended_anime_urls[0]})")
 
 
 
 
173
  st.image(recommended_anime_posters[0])
174
- with col2:
175
- st.write(f"[{recommended_anime_names[1]}]({recommended_anime_urls[1]})")
 
 
 
 
176
  st.image(recommended_anime_posters[1])
177
- with col3:
178
- st.write(f"[{recommended_anime_names[2]}]({recommended_anime_urls[2]})")
 
 
 
 
179
  st.image(recommended_anime_posters[2])
180
- with col4:
181
- st.write(f"[{recommended_anime_names[3]}]({recommended_anime_urls[3]})")
 
 
 
 
182
  st.image(recommended_anime_posters[3])
183
 
184
  st.divider()
185
 
186
  with st.container():
187
- col5, col6, col7, col8 = st.columns(4)
188
- with col5:
189
- st.write(f"[{recommended_anime_names[4]}]({recommended_anime_urls[4]})")
 
 
 
 
190
  st.image(recommended_anime_posters[4])
191
- with col6:
192
- st.write(f"[{recommended_anime_names[5]}]({recommended_anime_urls[5]})")
 
 
 
 
193
  st.image(recommended_anime_posters[5])
194
- with col7:
195
- st.write(f"[{recommended_anime_names[6]}]({recommended_anime_urls[6]})")
 
 
 
 
196
  st.image(recommended_anime_posters[6])
197
- with col8:
198
- st.write(f"[{recommended_anime_names[7]}]({recommended_anime_urls[7]})")
 
 
 
 
199
  st.image(recommended_anime_posters[7])
200
 
201
 
202
  # Function to display the top 8 animes with user given anime name and genre
203
  def top_animes_custom_genres(anime_select, genre_select):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  (
205
  recommended_anime_names,
206
  recommended_anime_posters,
207
  recommended_anime_urls,
208
  ) = recommend(anime_select, genre_select)
209
  with st.container():
210
- col1, col2, col3, col4 = st.columns(4)
211
- with col1:
212
- st.write(f"[{recommended_anime_names[0]}]({recommended_anime_urls[0]})")
 
 
 
 
213
  st.image(recommended_anime_posters[0])
214
- with col2:
215
- st.write(f"[{recommended_anime_names[1]}]({recommended_anime_urls[1]})")
 
 
 
 
216
  st.image(recommended_anime_posters[1])
217
- with col3:
218
- st.write(f"[{recommended_anime_names[2]}]({recommended_anime_urls[2]})")
 
 
 
 
219
  st.image(recommended_anime_posters[2])
220
- with col4:
221
- st.write(f"[{recommended_anime_names[3]}]({recommended_anime_urls[3]})")
 
 
 
 
222
  st.image(recommended_anime_posters[3])
223
 
224
  st.divider()
225
 
226
  with st.container():
227
- col5, col6, col7, col8 = st.columns(4)
228
- with col5:
229
- st.write(f"[{recommended_anime_names[4]}]({recommended_anime_urls[4]})")
 
 
 
 
230
  st.image(recommended_anime_posters[4])
231
- with col6:
232
- st.write(f"[{recommended_anime_names[5]}]({recommended_anime_urls[5]})")
 
 
 
 
233
  st.image(recommended_anime_posters[5])
234
- with col7:
235
- st.write(f"[{recommended_anime_names[6]}]({recommended_anime_urls[6]})")
 
 
 
 
236
  st.image(recommended_anime_posters[6])
237
- with col8:
238
- st.write(f"[{recommended_anime_names[7]}]({recommended_anime_urls[7]})")
 
 
 
 
239
  st.image(recommended_anime_posters[7])
240
 
241
 
@@ -243,18 +439,19 @@ def top_animes_custom_genres(anime_select, genre_select):
243
  def recommender_page():
244
  style_for_page = """
245
  <style>
246
- div.css-1v0mbdj.etr89bj1>img {
247
- width: 100%;
248
- height: 100%;
249
- overflow: hidden;
250
- box-shadow: 0 0 0 1px rgba(0,0,0,.1);
251
- border-radius: 1rem;
 
252
  }
253
  </style>
254
  """
255
  st.markdown(style_for_page, unsafe_allow_html=True)
256
 
257
- st.title("Anime Recommendation System")
258
 
259
  anime_list = anime_data["title"].tolist()
260
  anime_list.sort()
 
88
 
89
  # Function to display the top 8 animes with the highest rating
90
  def top_animes():
91
+ style_for_page = """
92
+ <style>
93
+ div.st-emotion-cache-1v0mbdj.e115fcil1>img {
94
+ border-radius: 10px;
95
+ }
96
+ a.st-emotion-cache-1lbx6hs.e16zdaao0 {
97
+ border-radius: 15px;
98
+ text-align: center;
99
+ }
100
+ a.st-emotion-cache-1lbx6hs.e16zdaao0:hover {
101
+ scale: 1.05;
102
+ transition-duration: 0.3s;
103
+ }
104
+ </style>
105
+ """
106
+ st.markdown(style_for_page, unsafe_allow_html=True)
107
+
108
  top8 = anime_data.sort_values("score", ascending=False).head(8)
109
 
110
  with st.container():
111
+ col0, col1, col2, col3 = st.columns(4)
112
+ with col0:
113
+ st.link_button(
114
+ f"{top8.iloc[0].title}",
115
+ f"{top8.iloc[0].anime_url}",
116
+ use_container_width=True,
117
+ )
118
  st.image(top8.iloc[0].poster)
119
+ with col1:
120
+ st.link_button(
121
+ f"{top8.iloc[1].title}",
122
+ f"{top8.iloc[1].anime_url}",
123
+ use_container_width=True,
124
+ )
125
  st.image(top8.iloc[1].poster)
126
+ with col2:
127
+ st.link_button(
128
+ f"{top8.iloc[2].title}",
129
+ f"{top8.iloc[2].anime_url}",
130
+ use_container_width=True,
131
+ )
132
  st.image(top8.iloc[2].poster)
133
+ with col3:
134
+ st.link_button(
135
+ f"{top8.iloc[3].title}",
136
+ f"{top8.iloc[3].anime_url}",
137
+ use_container_width=True,
138
+ )
139
  st.image(top8.iloc[3].poster)
140
 
141
  st.divider()
142
 
143
  with st.container():
144
+ col4, col5, col6, col7 = st.columns(4)
145
+ with col4:
146
+ st.link_button(
147
+ f"{top8.iloc[4].title}",
148
+ f"{top8.iloc[4].anime_url}",
149
+ use_container_width=True,
150
+ )
151
  st.image(top8.iloc[4].poster)
152
+ with col5:
153
+ st.link_button(
154
+ f"{top8.iloc[5].title}",
155
+ f"{top8.iloc[5].anime_url}",
156
+ use_container_width=True,
157
+ )
158
  st.image(top8.iloc[5].poster)
159
+ with col6:
160
+ st.link_button(
161
+ f"{top8.iloc[6].title}",
162
+ f"{top8.iloc[6].anime_url}",
163
+ use_container_width=True,
164
+ )
165
  st.image(top8.iloc[6].poster)
166
+ with col7:
167
+ st.link_button(
168
+ f"{top8.iloc[7].title}",
169
+ f"{top8.iloc[7].anime_url}",
170
+ use_container_width=True,
171
+ )
172
  st.image(top8.iloc[7].poster)
173
 
174
 
175
  # Function to display the top 8 animes for user given genre
176
  def top_animes_genres(genre_select):
177
+ style_for_page = """
178
+ <style>
179
+ div.st-emotion-cache-1v0mbdj.e115fcil1>img {
180
+ border-radius: 10px;
181
+ }
182
+ a.st-emotion-cache-1lbx6hs.e16zdaao0 {
183
+ border-radius: 15px;
184
+ text-align: center;
185
+ }
186
+ a.st-emotion-cache-1lbx6hs.e16zdaao0:hover {
187
+ scale: 1.05;
188
+ transition-duration: 0.3s;
189
+ }
190
+ </style>
191
+ """
192
+ st.markdown(style_for_page, unsafe_allow_html=True)
193
+
194
  top_8_genre = anime_data[
195
  anime_data["genres"].str.contains(genre_select)
196
  ].sort_values("score", ascending=False)[:8]
197
+ col0, col1, col2, col3 = st.columns(4)
198
+ with col0:
199
+ st.link_button(
200
+ f"{top_8_genre.iloc[0].title}",
201
+ f"{top_8_genre.iloc[0].anime_url}",
202
+ use_container_width=True,
203
+ )
204
  st.image(top_8_genre.iloc[0].poster)
205
+ with col1:
206
+ st.link_button(
207
+ f"{top_8_genre.iloc[1].title}",
208
+ f"{top_8_genre.iloc[1].anime_url}",
209
+ use_container_width=True,
210
+ )
211
  st.image(top_8_genre.iloc[1].poster)
212
+ with col2:
213
+ st.link_button(
214
+ f"{top_8_genre.iloc[2].title}",
215
+ f"{top_8_genre.iloc[2].anime_url}",
216
+ use_container_width=True,
217
+ )
218
  st.image(top_8_genre.iloc[2].poster)
219
+ with col3:
220
+ st.link_button(
221
+ f"{top_8_genre.iloc[3].title}",
222
+ f"{top_8_genre.iloc[3].anime_url}",
223
+ use_container_width=True,
224
+ )
225
  st.image(top_8_genre.iloc[3].poster)
226
 
227
  st.divider()
228
 
229
+ col4, col5, col6, col7 = st.columns(4)
230
+ with col4:
231
+ st.link_button(
232
+ f"{top_8_genre.iloc[4].title}",
233
+ f"{top_8_genre.iloc[4].anime_url}",
234
+ use_container_width=True,
235
+ )
236
  st.image(top_8_genre.iloc[4].poster)
237
+ with col5:
238
+ st.link_button(
239
+ f"{top_8_genre.iloc[5].title}",
240
+ f"{top_8_genre.iloc[5].anime_url}",
241
+ use_container_width=True,
242
+ )
243
  st.image(top_8_genre.iloc[5].poster)
244
+ with col6:
245
+ st.link_button(
246
+ f"{top_8_genre.iloc[6].title}",
247
+ f"{top_8_genre.iloc[6].anime_url}",
248
+ use_container_width=True,
249
+ )
250
  st.image(top_8_genre.iloc[6].poster)
251
+ with col7:
252
+ st.link_button(
253
+ f"{top_8_genre.iloc[7].title}",
254
+ f"{top_8_genre.iloc[7].anime_url}",
255
+ use_container_width=True,
256
+ )
257
  st.image(top_8_genre.iloc[7].poster)
258
 
259
 
260
  # Function to display the top 8 animes with user given anime name for all genres
261
  def top_animes_custom(anime_select):
262
+ style_for_page = """
263
+ <style>
264
+ div.st-emotion-cache-1v0mbdj.e115fcil1>img {
265
+ border-radius: 10px;
266
+ }
267
+ a.st-emotion-cache-1lbx6hs.e16zdaao0 {
268
+ border-radius: 15px;
269
+ text-align: center;
270
+ }
271
+ a.st-emotion-cache-1lbx6hs.e16zdaao0:hover {
272
+ scale: 1.05;
273
+ transition-duration: 0.3s;
274
+ }
275
+ </style>
276
+ """
277
+ st.markdown(style_for_page, unsafe_allow_html=True)
278
+
279
  (
280
  recommended_anime_names,
281
  recommended_anime_posters,
282
  recommended_anime_urls,
283
  ) = recommend(anime_select)
284
  with st.container():
285
+ col0, col1, col2, col3 = st.columns(4)
286
+ with col0:
287
+ st.link_button(
288
+ f"{recommended_anime_names[0]}",
289
+ f"{recommended_anime_urls[0]}",
290
+ use_container_width=True,
291
+ )
292
  st.image(recommended_anime_posters[0])
293
+ with col1:
294
+ st.link_button(
295
+ f"{recommended_anime_names[1]}",
296
+ f"{recommended_anime_urls[1]}",
297
+ use_container_width=True,
298
+ )
299
  st.image(recommended_anime_posters[1])
300
+ with col2:
301
+ st.link_button(
302
+ f"{recommended_anime_names[2]}",
303
+ f"{recommended_anime_urls[2]}",
304
+ use_container_width=True,
305
+ )
306
  st.image(recommended_anime_posters[2])
307
+ with col3:
308
+ st.link_button(
309
+ f"{recommended_anime_names[3]}",
310
+ f"{recommended_anime_urls[3]}",
311
+ use_container_width=True,
312
+ )
313
  st.image(recommended_anime_posters[3])
314
 
315
  st.divider()
316
 
317
  with st.container():
318
+ col4, col5, col6, col7 = st.columns(4)
319
+ with col4:
320
+ st.link_button(
321
+ f"{recommended_anime_names[4]}",
322
+ f"{recommended_anime_urls[4]}",
323
+ use_container_width=True,
324
+ )
325
  st.image(recommended_anime_posters[4])
326
+ with col5:
327
+ st.link_button(
328
+ f"{recommended_anime_names[5]}",
329
+ f"{recommended_anime_urls[5]}",
330
+ use_container_width=True,
331
+ )
332
  st.image(recommended_anime_posters[5])
333
+ with col6:
334
+ st.link_button(
335
+ f"{recommended_anime_names[6]}",
336
+ f"{recommended_anime_urls[6]}",
337
+ use_container_width=True,
338
+ )
339
  st.image(recommended_anime_posters[6])
340
+ with col7:
341
+ st.link_button(
342
+ f"{recommended_anime_names[7]}",
343
+ f"{recommended_anime_urls[7]}",
344
+ use_container_width=True,
345
+ )
346
  st.image(recommended_anime_posters[7])
347
 
348
 
349
  # Function to display the top 8 animes with user given anime name and genre
350
  def top_animes_custom_genres(anime_select, genre_select):
351
+ style_for_page = """
352
+ <style>
353
+ div.st-emotion-cache-1v0mbdj.e115fcil1>img {
354
+ border-radius: 10px;
355
+ }
356
+ a.st-emotion-cache-1lbx6hs.e16zdaao0 {
357
+ border-radius: 15px;
358
+ text-align: center;
359
+ }
360
+ a.st-emotion-cache-1lbx6hs.e16zdaao0:hover {
361
+ scale: 1.05;
362
+ transition-duration: 0.3s;
363
+ }
364
+ </style>
365
+ """
366
+ st.markdown(style_for_page, unsafe_allow_html=True)
367
+
368
  (
369
  recommended_anime_names,
370
  recommended_anime_posters,
371
  recommended_anime_urls,
372
  ) = recommend(anime_select, genre_select)
373
  with st.container():
374
+ col0, col1, col2, col3 = st.columns(4)
375
+ with col0:
376
+ st.link_button(
377
+ f"{recommended_anime_names[0]}",
378
+ f"{recommended_anime_urls[0]}",
379
+ use_container_width=True,
380
+ )
381
  st.image(recommended_anime_posters[0])
382
+ with col1:
383
+ st.link_button(
384
+ f"{recommended_anime_names[1]}",
385
+ f"{recommended_anime_urls[1]}",
386
+ use_container_width=True,
387
+ )
388
  st.image(recommended_anime_posters[1])
389
+ with col2:
390
+ st.link_button(
391
+ f"{recommended_anime_names[2]}",
392
+ f"{recommended_anime_urls[2]}",
393
+ use_container_width=True,
394
+ )
395
  st.image(recommended_anime_posters[2])
396
+ with col3:
397
+ st.link_button(
398
+ f"{recommended_anime_names[3]}",
399
+ f"{recommended_anime_urls[3]}",
400
+ use_container_width=True,
401
+ )
402
  st.image(recommended_anime_posters[3])
403
 
404
  st.divider()
405
 
406
  with st.container():
407
+ col4, col5, col6, col7 = st.columns(4)
408
+ with col4:
409
+ st.link_button(
410
+ f"{recommended_anime_names[4]}",
411
+ f"{recommended_anime_urls[4]}",
412
+ use_container_width=True,
413
+ )
414
  st.image(recommended_anime_posters[4])
415
+ with col5:
416
+ st.link_button(
417
+ f"{recommended_anime_names[5]}",
418
+ f"{recommended_anime_urls[5]}",
419
+ use_container_width=True,
420
+ )
421
  st.image(recommended_anime_posters[5])
422
+ with col6:
423
+ st.link_button(
424
+ f"{recommended_anime_names[6]}",
425
+ f"{recommended_anime_urls[6]}",
426
+ use_container_width=True,
427
+ )
428
  st.image(recommended_anime_posters[6])
429
+ with col7:
430
+ st.link_button(
431
+ f"{recommended_anime_names[7]}",
432
+ f"{recommended_anime_urls[7]}",
433
+ use_container_width=True,
434
+ )
435
  st.image(recommended_anime_posters[7])
436
 
437
 
 
439
  def recommender_page():
440
  style_for_page = """
441
  <style>
442
+ button.st-emotion-cache-c766yy.ef3psqc11 {
443
+ border-radius: 10px;
444
+ }
445
+
446
+ button.st-emotion-cache-c766yy.ef3psqc11:hover {
447
+ scale: 1.05;
448
+ transition-duration: 0.3s;
449
  }
450
  </style>
451
  """
452
  st.markdown(style_for_page, unsafe_allow_html=True)
453
 
454
+ st.title("Anime Recommendation System :ninja:")
455
 
456
  anime_list = anime_data["title"].tolist()
457
  anime_list.sort()
app.py CHANGED
@@ -27,26 +27,8 @@ show_pages(
27
  def home_page():
28
  style_for_page = """
29
  <style>
30
- div.css-1v0mbdj.etr89bj1>img {
31
- width: 100%;
32
- height: 100%;
33
- box-shadow: 0 0 0 1px rgba(0,0,0,.1);
34
- border-radius: 5rem;
35
- padding: 4rem;
36
- justify-content: left;}
37
-
38
- div.css-k7vsyb.e16nr0p31>h1 {
39
- font-family: Poppins, sans-serif;
40
- }
41
-
42
- div.css-14xtw13.e8zbici0 {
43
- margin-right: 2rem;
44
- scale: 1.15;
45
- }
46
-
47
- div.css-nahz7x.e16nr0p34>p {
48
- font-family: Poppins, sans-serif;
49
- font-size: 1.05rem;
50
  }
51
  </style>
52
  """
@@ -60,7 +42,8 @@ def home_page():
60
  "Explore a world of anime and find personalized recommendations based on your anime preferences."
61
  )
62
  img = Image.open(r"animes.jpg")
63
- st.image(img, use_column_width=True, caption="Anime Characters")
 
64
  st.write(
65
  "Get started by selecting your favorite anime and let the recommendation system do the rest!"
66
  )
 
27
  def home_page():
28
  style_for_page = """
29
  <style>
30
+ div.st-emotion-cache-1v0mbdj.e115fcil1>img {
31
+ border-radius: 50px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
  </style>
34
  """
 
42
  "Explore a world of anime and find personalized recommendations based on your anime preferences."
43
  )
44
  img = Image.open(r"animes.jpg")
45
+ with st.container():
46
+ st.image(img, width=950, caption="Anime Characters")
47
  st.write(
48
  "Get started by selecting your favorite anime and let the recommendation system do the rest!"
49
  )