shivmeev commited on
Commit
8fa681c
·
verified ·
1 Parent(s): cd84f61

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -3
app.py CHANGED
@@ -1,7 +1,43 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  demo.launch()
 
1
  import gradio as gr
2
 
3
+ import pandas as pd
4
+ import numpy as np
5
+ import torch
6
+ import torch.nn as nn
7
+ import gradio as gr
8
+
9
+ model = nn.Sequential(
10
+ nn.Linear(11, 20),
11
+ nn.ReLU(),
12
+ nn.Linear(20, 5, bias=True))
13
+
14
+ PATH = "wine_model.pth"
15
+
16
+ model.load_state_dict(torch.load(PATH, weights_only=False))
17
+
18
+ def forward(model, input):
19
+ preds = model(input)
20
+ predicted_class = torch.argmax(preds, dim=-1) + 4
21
+ return predicted_class
22
+
23
+ with gr.Blocks() as demo:
24
+ gr.Markdown("Enter your wine data below:")
25
+ input_df = gr.Dataframe(
26
+ row_count=(2, "dynamic"), # Allows adding/removing rows
27
+ col_count=(11, "dynamic"), # Allows adding/removing columns
28
+ headers=list(df.columns)[:-1],
29
+ label="Input Data",
30
+ interactive=True,
31
+ type="pandas" # Specify the desired input type for your function
32
+ )
33
+ output_text = gr.Textbox(label="Processed Output")
34
+
35
+ def process_data(input_dataframe):
36
+ # Perform operations on the input_dataframe
37
+ if isinstance(input_dataframe, pd.DataFrame):
38
+ return forward(model, input_dataframe)
39
+ return "Invalid input type"
40
+
41
+ input_df.change(fn=process_data, inputs=input_df, outputs=output_text)
42
 
 
43
  demo.launch()