Spaces:
Sleeping
Sleeping
Update helper.py
Browse files
helper.py
CHANGED
|
@@ -6,6 +6,21 @@ import json
|
|
| 6 |
from typing import List, Dict, Any
|
| 7 |
from openai import OpenAI
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def resize_image(image: Image.Image) -> Image.Image:
|
| 10 |
new_height = int(image.height * 512 / image.width)
|
| 11 |
return image.resize((512, new_height))
|
|
|
|
| 6 |
from typing import List, Dict, Any
|
| 7 |
from openai import OpenAI
|
| 8 |
|
| 9 |
+
import streamlit as st
|
| 10 |
+
import streamlit.components.v1 as components
|
| 11 |
+
|
| 12 |
+
# Function to render custom HTML file uploader
|
| 13 |
+
def custom_file_uploader():
|
| 14 |
+
uploader_html = """
|
| 15 |
+
<input type="file" id="fileUpload" accept=".png,.jpg,.jpeg" />
|
| 16 |
+
<script>
|
| 17 |
+
// Hide the 'Take photo' option (works on some browsers, not universally enforced)
|
| 18 |
+
document.getElementById("fileUpload").capture = false;
|
| 19 |
+
</script>
|
| 20 |
+
"""
|
| 21 |
+
# Embedding custom HTML uploader
|
| 22 |
+
components.html(uploader_html, height=100)
|
| 23 |
+
|
| 24 |
def resize_image(image: Image.Image) -> Image.Image:
|
| 25 |
new_height = int(image.height * 512 / image.width)
|
| 26 |
return image.resize((512, new_height))
|