Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,17 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
model = repo_id # Loads the inference function (predict_price)
|
7 |
|
8 |
-
|
9 |
-
def predict_with_hf_model(size, bedrooms, age):
|
10 |
-
"""Predicts house price using the model from Hugging Face Hub."""
|
11 |
-
# Call the loaded inference function
|
12 |
-
result = model.predict_price(size=size, bedrooms=bedrooms, age=age)
|
13 |
-
predicted_price = result["predicted_price"] # Extract the predicted price
|
14 |
-
|
15 |
-
# Format the output
|
16 |
-
return f"Predicted Price: ${predicted_price:,.2f}"
|
17 |
-
|
18 |
-
|
19 |
-
# Create the Gradio interface
|
20 |
iface = gr.Interface(
|
21 |
-
fn=
|
22 |
-
inputs=
|
23 |
outputs="text",
|
24 |
-
title="
|
25 |
-
description="Enter house details to predict the price.",
|
26 |
)
|
27 |
|
28 |
-
# Launch the interface
|
29 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import from_pretrained
|
3 |
|
4 |
+
# Load the model (try with a built-in model first)
|
5 |
+
model = from_pretrained("bert-base-uncased") # Or any other built-in HF model
|
6 |
|
7 |
+
def predict_simple(text):
|
8 |
+
return {"result": text.upper()}
|
|
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
iface = gr.Interface(
|
11 |
+
fn=predict_simple,
|
12 |
+
inputs="text",
|
13 |
outputs="text",
|
14 |
+
title="Simple Text Uppercasing",
|
|
|
15 |
)
|
16 |
|
|
|
17 |
iface.launch()
|