Spaces:
Sleeping
Sleeping
Upload app_gradio.py
Browse files- app_gradio.py +46 -0
app_gradio.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""app_gradio.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1hRynOROyrpbf0wKKcizHOXeZhx3Xo51M
|
8 |
+
"""
|
9 |
+
|
10 |
+
import numpy as np
|
11 |
+
|
12 |
+
import plotly.express as px
|
13 |
+
import pandas as pd
|
14 |
+
|
15 |
+
import gradio
|
16 |
+
|
17 |
+
import plotly.graph_objects as go
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
taraf_s = pd.read_csv('/content/drive/MyDrive/Hadith Project/taraf_by_year.csv')
|
22 |
+
|
23 |
+
taraf_s = taraf_s.sort_values(['City', 'Year'], ascending=True)
|
24 |
+
|
25 |
+
cities = taraf_s['City'].unique().tolist()
|
26 |
+
min_year = int(taraf_s['Year'].min())
|
27 |
+
max_year = int(taraf_s['Year'].max())
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
def plot_timeline(citi = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], min_year = 0, max_year = 400):
|
32 |
+
filtered = taraf_s[taraf_s['City'].isin(citi) & (taraf_s['Year'] >= min_year) & (taraf_s['Year'] <= max_year)]
|
33 |
+
fig = px.line(data_frame = filtered, x = 'Year', y = 'Taraf', title = "Tarafs per Year", color = 'City' )
|
34 |
+
fig.update_layout(title_font_color = 'red', title_x = .5)
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
return fig
|
39 |
+
|
40 |
+
app = gradio.Interface(plot_timeline,
|
41 |
+
[gradio.Dropdown(choices = cities, value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True),
|
42 |
+
gradio.Slider(min_year, max_year, value = 0, label = 'Begining', info = 'Choose the first year to display Tarafs'),
|
43 |
+
gradio.Slider(min_year, max_year, value = 400, label = 'End', info = 'Choose the last year to display Tarafs')
|
44 |
+
|
45 |
+
],
|
46 |
+
gradio.Plot()).launch(share = True)
|