Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
|
5 |
+
def process_output(prediction):
|
6 |
+
# Assuming the tuple contains numpy arrays representing images
|
7 |
+
if isinstance(prediction, tuple):
|
8 |
+
# Convert the first element of the tuple to an image
|
9 |
+
image_array = prediction[0]
|
10 |
+
image = Image.fromarray(image_array.astype('uint8'))
|
11 |
+
return image
|
12 |
+
return prediction
|
13 |
+
|
14 |
+
def predict(input_data):
|
15 |
+
# Load your model and get the prediction
|
16 |
+
prediction = some_model.predict(input_data)
|
17 |
+
return process_output(prediction)
|
18 |
+
|
19 |
+
interface = gr.Interface(fn=predict, inputs="text", outputs="image")
|
20 |
+
interface.launch()
|