Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import matplotlib.pyplot as plt
|
|
|
|
|
4 |
import logging
|
5 |
|
6 |
logging.basicConfig(level=logging.DEBUG)
|
@@ -15,8 +17,13 @@ def display_sketch(sketch):
|
|
15 |
|
16 |
plt.imshow(image_data, cmap='gray')
|
17 |
plt.axis('off')
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
else:
|
21 |
error_message = f"Unexpected sketch data format: {type(sketch)}"
|
22 |
logging.error(error_message)
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import matplotlib.pyplot as plt
|
4 |
+
import tempfile
|
5 |
+
import os
|
6 |
import logging
|
7 |
|
8 |
logging.basicConfig(level=logging.DEBUG)
|
|
|
17 |
|
18 |
plt.imshow(image_data, cmap='gray')
|
19 |
plt.axis('off')
|
20 |
+
|
21 |
+
# Use a temporary directory for saving the image
|
22 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
|
23 |
+
plt.savefig(temp_file.name, bbox_inches='tight')
|
24 |
+
temp_file_path = temp_file.name
|
25 |
+
|
26 |
+
return temp_file_path
|
27 |
else:
|
28 |
error_message = f"Unexpected sketch data format: {type(sketch)}"
|
29 |
logging.error(error_message)
|