sengeolab commited on
Commit
13a3514
·
verified ·
1 Parent(s): 19c6b02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -1,3 +1,28 @@
1
  import gradio as gr
2
 
3
- gr.load("models/sengeolab/geocoder").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ #gr.load("models/sengeolab/geocoder").launch()
4
+ #import gradio as gr
5
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
6
+
7
+ # Load the model and tokenizer
8
+ model_name = "sengeolab/geocoder" # This should be the correct model identifier
9
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
10
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
11
+
12
+ # Define your Gradio interface
13
+ inputs = gr.Textbox(lines=3, label="Input Address")
14
+ outputs = gr.Label(label="Geocoded Location")
15
+
16
+ def geocode_address(address):
17
+ # Tokenize the input text
18
+ inputs = tokenizer(address, return_tensors="pt", padding=True, truncation=True)
19
+
20
+ # Perform inference
21
+ outputs = model(**inputs)
22
+ # Add your inference logic here
23
+ # For example, you can process the outputs and return the geocoded location
24
+
25
+ return "Geocoded Location" # Replace this with your actual output
26
+
27
+ # Launch the Gradio interface
28
+ gr.Interface(fn=geocode_address, inputs=inputs, outputs=outputs).launch()