Spaces:
Running
Running
File size: 767 Bytes
b1a73d9 ec196b6 a476eb9 b1a73d9 a476eb9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import torch
import gradio as gr
def process_text(input_text):
# Example CUDA processing: reverse the input string and move to GPU
if torch.cuda.is_available():
device = torch.device("cuda")
tensor = torch.tensor([ord(c) for c in input_text], device=device)
reversed_tensor = tensor.flip(0)
output_text = ''.join([chr(int(c)) for c in reversed_tensor.cpu()])
return output_text
else:
return "CUDA is not available."
# Define the Gradio interface
interface = gr.Interface(
fn=process_text, # Function to process input
inputs=gr.Textbox(label="Enter text"), # Input component
outputs=gr.Textbox(label="Output") # Output component
)
# Launch the Gradio app
interface.launch()
|