Abid commited on
Commit
6e8e639
1 Parent(s): 5d43a5e

gradio image app

Browse files
Files changed (3) hide show
  1. Procfile +1 -1
  2. app_savta.py +17 -0
  3. app_table.py +0 -36
Procfile CHANGED
@@ -1 +1 @@
1
- web: source setup.sh && python app_table.py
 
1
+ web: source setup.sh && python app_savta.py
app_savta.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ import gradio as gr
4
+
5
+
6
+ def sepia(input_img):
7
+ sepia_filter = np.array(
8
+ [[0.393, 0.769, 0.189], [0.349, 0.686, 0.168], [0.272, 0.534, 0.131]]
9
+ )
10
+ sepia_img = input_img.dot(sepia_filter.T)
11
+ sepia_img /= sepia_img.max()
12
+ return sepia_img
13
+
14
+
15
+ iface = gr.Interface(sepia, gr.inputs.Image(shape=(200, 200)), "image")
16
+
17
+ iface.launch(auth=("admin", "pass1234"))
app_table.py DELETED
@@ -1,36 +0,0 @@
1
- import matplotlib.pyplot as plt
2
- import numpy as np
3
- import pandas as pd
4
-
5
- import gradio as gr
6
-
7
-
8
- def sales_projections(employee_data):
9
- sales_data = employee_data.iloc[:, 1:4].astype("int").to_numpy()
10
- regression_values = np.apply_along_axis(
11
- lambda row: np.array(np.poly1d(np.polyfit([0, 1, 2], row, 2))), 0, sales_data
12
- )
13
- projected_months = np.repeat(
14
- np.expand_dims(np.arange(3, 12), 0), len(sales_data), axis=0
15
- )
16
- projected_values = np.array(
17
- [
18
- month * month * regression[0] + month * regression[1] + regression[2]
19
- for month, regression in zip(projected_months, regression_values)
20
- ]
21
- )
22
- plt.plot(projected_values.T)
23
- plt.legend(employee_data["Name"])
24
- return employee_data, plt.gcf(), regression_values
25
-
26
-
27
- iface = gr.Interface(
28
- sales_projections,
29
- gr.inputs.Dataframe(
30
- headers=["Name", "Jan Sales", "Feb Sales", "Mar Sales"],
31
- default=[["Jon", 12, 14, 18], ["Alice", 14, 17, 2], ["Sana", 8, 9.5, 12]],
32
- ),
33
- ["dataframe", "plot", "numpy"],
34
- description="Enter sales figures for employees to predict sales trajectory over year.",
35
- )
36
- iface.launch(auth=("admin", "pass1234"))