Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,15 @@
|
|
1 |
-
import
|
2 |
|
3 |
def process_text(input_text):
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# Define the Gradio interface
|
7 |
interface = gr.Interface(
|
|
|
1 |
+
import torch
|
2 |
|
3 |
def process_text(input_text):
|
4 |
+
# Example CUDA processing: reverse the input string and move to GPU
|
5 |
+
if torch.cuda.is_available():
|
6 |
+
device = torch.device("cuda")
|
7 |
+
tensor = torch.tensor([ord(c) for c in input_text], device=device)
|
8 |
+
reversed_tensor = tensor.flip(0)
|
9 |
+
output_text = ''.join([chr(int(c)) for c in reversed_tensor.cpu()])
|
10 |
+
return output_text
|
11 |
+
else:
|
12 |
+
return "CUDA is not available."
|
13 |
|
14 |
# Define the Gradio interface
|
15 |
interface = gr.Interface(
|