Spaces:
Sleeping
Sleeping
File size: 1,369 Bytes
b6f83d2 1d27a08 b6f83d2 1d27a08 c8e9a92 1445dc5 b6f83d2 c8e9a92 07d5852 b6f83d2 93c47ac b27c5d2 36d1234 b27c5d2 4d9a68f b6f83d2 70991a4 1b364b1 c686fc0 1b364b1 c686fc0 1b364b1 7e6c312 70991a4 4d9a68f 7d2fada 1bb9498 7e6c312 b6f83d2 8760cb9 7e6c312 70991a4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import gradio as gr
import requests
import os
API_TOKEN = os.getenv('API_TOKEN')
API_URL = "https://api-inference.huggingface.co/models/nasa-impact/nasa-smd-ibm-v0.1"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
def get_model_output(input_text):
payload = {
"inputs": input_text
}
#output = query({"inputs": "The answer to the universe is <mask>.", })
output = query(payload)
results = []
for item in output:
sequence = item.get('sequence', '')
score = item.get('score', 0)
results.append(f"{sequence} (Score: {score:.4f})")
return "\n".join(results)
# Define Gradio interface
article_text = """
### Notes:
### Possible Demo Apps:
1. **Data Cleaning and Imputation**
2. **Content Generation and Brainstorming**
3. **Code Completion and Documentation**
"""
demo = gr.Interface(
fn=get_model_output,
inputs=gr.Textbox(lines=2, label="Input with mask token", placeholder="Enter a sentence with <mask> to fill..."),
outputs="text", # Display the output as JSON to inspect the response structure
title="nasa-smd-ibm-v0.1 Model Output",
description="NASA SMD Indus model response (Fill Mask).",
article=article_text
)
# Launch the interface
demo.launch()
|