Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- .gitattributes +35 -35
- README.md +14 -14
- app.py +198 -198
- requirements.txt +3 -3
.gitattributes
CHANGED
|
@@ -1,35 +1,35 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: EmDashCounter
|
| 3 |
-
emoji: π§ββοΈ
|
| 4 |
-
colorFrom: purple
|
| 5 |
-
colorTo: green
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 6.14.0
|
| 8 |
-
python_version: '3.13'
|
| 9 |
-
app_file: app.py
|
| 10 |
-
pinned: false
|
| 11 |
-
license: mit
|
| 12 |
-
---
|
| 13 |
-
|
| 14 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: EmDashCounter
|
| 3 |
+
emoji: π§ββοΈ
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 6.14.0
|
| 8 |
+
python_version: '3.13'
|
| 9 |
+
app_file: app.py
|
| 10 |
+
pinned: false
|
| 11 |
+
license: mit
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -1,198 +1,198 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import requests
|
| 3 |
-
import zipfile
|
| 4 |
-
import io
|
| 5 |
-
import os
|
| 6 |
-
from pypdf import PdfReader
|
| 7 |
-
|
| 8 |
-
# Video URL of The Count
|
| 9 |
-
VIDEO_URL = "https://images-ext-1.discordapp.net/external/PD3SdBHrOGxZtFU8zypW2PjGXabBG-OwY3rXB8XWG7Y/https/media.tenor.com/1nFPylOyXZIAAAPo/sesame-street-the-count.mp4"
|
| 10 |
-
|
| 11 |
-
def get_count_response(count):
|
| 12 |
-
if count == 0:
|
| 13 |
-
return "Zero! Zero em dashes! Ah ah ah!"
|
| 14 |
-
elif count == 1:
|
| 15 |
-
return "One! One em dash! Ah ah ah!"
|
| 16 |
-
elif count <= 20:
|
| 17 |
-
counting = " ".join([f"{i}!" for i in range(1, count + 1)])
|
| 18 |
-
return f"{counting} {count} em dashes! Ah ah ah!"
|
| 19 |
-
else:
|
| 20 |
-
return f"One! Two! Three! ... {count}! {count} em dashes! Ah ah ah!"
|
| 21 |
-
|
| 22 |
-
def count_em_dashes_in_bytes(content_bytes, filename):
|
| 23 |
-
count = 0
|
| 24 |
-
ext = os.path.splitext(filename.lower())[1]
|
| 25 |
-
|
| 26 |
-
if ext == '.pdf':
|
| 27 |
-
try:
|
| 28 |
-
reader = PdfReader(io.BytesIO(content_bytes))
|
| 29 |
-
for page in reader.pages:
|
| 30 |
-
text = page.extract_text()
|
| 31 |
-
if text:
|
| 32 |
-
count += text.count('β')
|
| 33 |
-
except Exception:
|
| 34 |
-
pass
|
| 35 |
-
else:
|
| 36 |
-
# Assume text-based for other common extensions
|
| 37 |
-
try:
|
| 38 |
-
content = content_bytes.decode('utf-8', errors='ignore')
|
| 39 |
-
count = content.count('β')
|
| 40 |
-
except Exception:
|
| 41 |
-
pass
|
| 42 |
-
return count
|
| 43 |
-
|
| 44 |
-
def process_input(input_url, uploaded_file):
|
| 45 |
-
total_count = 0
|
| 46 |
-
processed = False
|
| 47 |
-
|
| 48 |
-
# Handle Uploaded File
|
| 49 |
-
if uploaded_file is not None:
|
| 50 |
-
with open(uploaded_file.name, "rb") as f:
|
| 51 |
-
file_bytes = f.read()
|
| 52 |
-
total_count += count_em_dashes_in_bytes(file_bytes, uploaded_file.name)
|
| 53 |
-
processed = True
|
| 54 |
-
|
| 55 |
-
# Handle URL
|
| 56 |
-
if input_url and input_url.strip():
|
| 57 |
-
url = input_url.strip()
|
| 58 |
-
|
| 59 |
-
# Check if it's likely a GitHub Repo
|
| 60 |
-
if "github.com" in url and "/archive/" not in url and not any(url.lower().endswith(ext) for ext in ['.pdf', '.txt', '.md', '.py', '.js']):
|
| 61 |
-
# Normalize GitHub URL
|
| 62 |
-
base_url = url.rstrip('/')
|
| 63 |
-
if base_url.endswith('.git'):
|
| 64 |
-
base_url = base_url[:-4]
|
| 65 |
-
|
| 66 |
-
branches = ['main', 'master']
|
| 67 |
-
r = None
|
| 68 |
-
for branch in branches:
|
| 69 |
-
test_url = f"{base_url}/archive/refs/heads/{branch}.zip"
|
| 70 |
-
try:
|
| 71 |
-
response = requests.get(test_url, timeout=20)
|
| 72 |
-
if response.status_code == 200:
|
| 73 |
-
r = response
|
| 74 |
-
break
|
| 75 |
-
except Exception:
|
| 76 |
-
continue
|
| 77 |
-
|
| 78 |
-
if r:
|
| 79 |
-
try:
|
| 80 |
-
with zipfile.ZipFile(io.BytesIO(r.content)) as z:
|
| 81 |
-
for filename in z.namelist():
|
| 82 |
-
if filename.endswith('/'): continue
|
| 83 |
-
text_extensions = {'.py', '.md', '.txt', '.js', '.ts', '.html', '.css', '.c', '.cpp', '.h', '.java', '.rs', '.go', '.json', '.yml', '.yaml'}
|
| 84 |
-
if any(filename.lower().endswith(ext) for ext in text_extensions):
|
| 85 |
-
with z.open(filename) as f:
|
| 86 |
-
total_count += count_em_dashes_in_bytes(f.read(), filename)
|
| 87 |
-
processed = True
|
| 88 |
-
except Exception:
|
| 89 |
-
pass
|
| 90 |
-
else:
|
| 91 |
-
# Handle as single file URL
|
| 92 |
-
try:
|
| 93 |
-
response = requests.get(url, timeout=20)
|
| 94 |
-
if response.status_code == 200:
|
| 95 |
-
filename = url.split('/')[-1] or "file.txt"
|
| 96 |
-
total_count += count_em_dashes_in_bytes(response.content, filename)
|
| 97 |
-
processed = True
|
| 98 |
-
except Exception:
|
| 99 |
-
pass
|
| 100 |
-
|
| 101 |
-
if not processed:
|
| 102 |
-
return "I could not find anything to count! Provide a valid URL or upload a file! Ah ah ah!", gr.update(visible=False)
|
| 103 |
-
|
| 104 |
-
return get_count_response(total_count), gr.update(visible=True)
|
| 105 |
-
|
| 106 |
-
# Define custom CSS for a Sesame Street / The Count theme
|
| 107 |
-
custom_css = """
|
| 108 |
-
body, .gradio-container { background-color: #000000 !important; color: #e0e0e0 !important; font-family: 'Georgia', serif !important; }
|
| 109 |
-
.gr-box { background-color: #1a0633 !important; border: 2px solid #4b0082 !important; }
|
| 110 |
-
#large-input textarea, #large-input input {
|
| 111 |
-
background-color: #2b0b4d !important;
|
| 112 |
-
color: #ffffff !important;
|
| 113 |
-
font-size: 1.5rem !important;
|
| 114 |
-
border: 2px solid #9932cc !important;
|
| 115 |
-
}
|
| 116 |
-
#large-output textarea, #large-output input {
|
| 117 |
-
background-color: #000000 !important;
|
| 118 |
-
color: #32cd32 !important;
|
| 119 |
-
font-size: 1.8rem !important;
|
| 120 |
-
font-weight: bold !important;
|
| 121 |
-
border: 3px solid #32cd32 !important;
|
| 122 |
-
text-shadow: 2px 2px #1a0633;
|
| 123 |
-
}
|
| 124 |
-
#large-button {
|
| 125 |
-
background-color: #4b0082 !important;
|
| 126 |
-
color: #32cd32 !important;
|
| 127 |
-
font-size: 1.6rem !important;
|
| 128 |
-
font-weight: bold !important;
|
| 129 |
-
border: 4px solid #32cd32 !important;
|
| 130 |
-
height: 80px !important;
|
| 131 |
-
box-shadow: 0 0 10px #4b0082;
|
| 132 |
-
transition: all 0.3s ease;
|
| 133 |
-
cursor: pointer;
|
| 134 |
-
}
|
| 135 |
-
#large-button:hover {
|
| 136 |
-
background-color: #9932cc !important;
|
| 137 |
-
color: #ffffff !important;
|
| 138 |
-
box-shadow: 0 0 20px #32cd32;
|
| 139 |
-
transform: scale(1.02);
|
| 140 |
-
}
|
| 141 |
-
.gr-form label span {
|
| 142 |
-
font-size: 1.4rem !important;
|
| 143 |
-
color: #9932cc !important;
|
| 144 |
-
font-weight: bold !important;
|
| 145 |
-
text-transform: uppercase;
|
| 146 |
-
letter-spacing: 2px;
|
| 147 |
-
}
|
| 148 |
-
h1 { color: #9932cc !important; text-shadow: 2px 2px #000000 !important; font-size: 3rem !important; text-align: center !important; }
|
| 149 |
-
h3 { color: #e0e0e0 !important; text-align: center !important; margin-bottom: 2rem !important; }
|
| 150 |
-
.file-upload { background-color: #2b0b4d !important; border: 2px dashed #9932cc !important; }
|
| 151 |
-
"""
|
| 152 |
-
|
| 153 |
-
with gr.Blocks(title="The Count's Em Dash Counter"
|
| 154 |
-
gr.Markdown("# π§ββοΈ The Count's Em Dash Counter")
|
| 155 |
-
gr.Markdown("### Provide a GitHub repo, a file URL, or upload documents to count em dashes (β)! Ah ah ah!")
|
| 156 |
-
|
| 157 |
-
with gr.Row():
|
| 158 |
-
with gr.Column(scale=4):
|
| 159 |
-
repo_url = gr.Textbox(
|
| 160 |
-
label="GitHub or File URL",
|
| 161 |
-
placeholder="https://github.com/... OR https://example.com/file.pdf",
|
| 162 |
-
lines=1,
|
| 163 |
-
elem_id="large-input"
|
| 164 |
-
)
|
| 165 |
-
|
| 166 |
-
file_upload = gr.File(
|
| 167 |
-
label="Upload Documents (PDF, TXT, MD...)",
|
| 168 |
-
file_types=[".pdf", ".txt", ".md", ".py", ".js", ".ts", ".html", ".css", ".json"],
|
| 169 |
-
elem_classes="file-upload"
|
| 170 |
-
)
|
| 171 |
-
|
| 172 |
-
count_btn = gr.Button("Count them! Ah ah ah!", variant="primary", elem_id="large-button")
|
| 173 |
-
result_text = gr.Textbox(
|
| 174 |
-
label="The Count Says:",
|
| 175 |
-
interactive=False,
|
| 176 |
-
elem_id="large-output",
|
| 177 |
-
lines=3
|
| 178 |
-
)
|
| 179 |
-
|
| 180 |
-
with gr.Column(scale=5):
|
| 181 |
-
video = gr.Video(
|
| 182 |
-
value=VIDEO_URL,
|
| 183 |
-
label="The Count",
|
| 184 |
-
autoplay=True,
|
| 185 |
-
loop=True,
|
| 186 |
-
show_label=False,
|
| 187 |
-
interactive=False,
|
| 188 |
-
visible=False
|
| 189 |
-
)
|
| 190 |
-
|
| 191 |
-
count_btn.click(
|
| 192 |
-
fn=process_input,
|
| 193 |
-
inputs=[repo_url, file_upload],
|
| 194 |
-
outputs=[result_text, video]
|
| 195 |
-
)
|
| 196 |
-
|
| 197 |
-
if __name__ == "__main__":
|
| 198 |
-
demo.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import zipfile
|
| 4 |
+
import io
|
| 5 |
+
import os
|
| 6 |
+
from pypdf import PdfReader
|
| 7 |
+
|
| 8 |
+
# Video URL of The Count
|
| 9 |
+
VIDEO_URL = "https://images-ext-1.discordapp.net/external/PD3SdBHrOGxZtFU8zypW2PjGXabBG-OwY3rXB8XWG7Y/https/media.tenor.com/1nFPylOyXZIAAAPo/sesame-street-the-count.mp4"
|
| 10 |
+
|
| 11 |
+
def get_count_response(count):
|
| 12 |
+
if count == 0:
|
| 13 |
+
return "Zero! Zero em dashes! Ah ah ah!"
|
| 14 |
+
elif count == 1:
|
| 15 |
+
return "One! One em dash! Ah ah ah!"
|
| 16 |
+
elif count <= 20:
|
| 17 |
+
counting = " ".join([f"{i}!" for i in range(1, count + 1)])
|
| 18 |
+
return f"{counting} {count} em dashes! Ah ah ah!"
|
| 19 |
+
else:
|
| 20 |
+
return f"One! Two! Three! ... {count}! {count} em dashes! Ah ah ah!"
|
| 21 |
+
|
| 22 |
+
def count_em_dashes_in_bytes(content_bytes, filename):
|
| 23 |
+
count = 0
|
| 24 |
+
ext = os.path.splitext(filename.lower())[1]
|
| 25 |
+
|
| 26 |
+
if ext == '.pdf':
|
| 27 |
+
try:
|
| 28 |
+
reader = PdfReader(io.BytesIO(content_bytes))
|
| 29 |
+
for page in reader.pages:
|
| 30 |
+
text = page.extract_text()
|
| 31 |
+
if text:
|
| 32 |
+
count += text.count('β')
|
| 33 |
+
except Exception:
|
| 34 |
+
pass
|
| 35 |
+
else:
|
| 36 |
+
# Assume text-based for other common extensions
|
| 37 |
+
try:
|
| 38 |
+
content = content_bytes.decode('utf-8', errors='ignore')
|
| 39 |
+
count = content.count('β')
|
| 40 |
+
except Exception:
|
| 41 |
+
pass
|
| 42 |
+
return count
|
| 43 |
+
|
| 44 |
+
def process_input(input_url, uploaded_file):
|
| 45 |
+
total_count = 0
|
| 46 |
+
processed = False
|
| 47 |
+
|
| 48 |
+
# Handle Uploaded File
|
| 49 |
+
if uploaded_file is not None:
|
| 50 |
+
with open(uploaded_file.name, "rb") as f:
|
| 51 |
+
file_bytes = f.read()
|
| 52 |
+
total_count += count_em_dashes_in_bytes(file_bytes, uploaded_file.name)
|
| 53 |
+
processed = True
|
| 54 |
+
|
| 55 |
+
# Handle URL
|
| 56 |
+
if input_url and input_url.strip():
|
| 57 |
+
url = input_url.strip()
|
| 58 |
+
|
| 59 |
+
# Check if it's likely a GitHub Repo
|
| 60 |
+
if "github.com" in url and "/archive/" not in url and not any(url.lower().endswith(ext) for ext in ['.pdf', '.txt', '.md', '.py', '.js']):
|
| 61 |
+
# Normalize GitHub URL
|
| 62 |
+
base_url = url.rstrip('/')
|
| 63 |
+
if base_url.endswith('.git'):
|
| 64 |
+
base_url = base_url[:-4]
|
| 65 |
+
|
| 66 |
+
branches = ['main', 'master']
|
| 67 |
+
r = None
|
| 68 |
+
for branch in branches:
|
| 69 |
+
test_url = f"{base_url}/archive/refs/heads/{branch}.zip"
|
| 70 |
+
try:
|
| 71 |
+
response = requests.get(test_url, timeout=20)
|
| 72 |
+
if response.status_code == 200:
|
| 73 |
+
r = response
|
| 74 |
+
break
|
| 75 |
+
except Exception:
|
| 76 |
+
continue
|
| 77 |
+
|
| 78 |
+
if r:
|
| 79 |
+
try:
|
| 80 |
+
with zipfile.ZipFile(io.BytesIO(r.content)) as z:
|
| 81 |
+
for filename in z.namelist():
|
| 82 |
+
if filename.endswith('/'): continue
|
| 83 |
+
text_extensions = {'.py', '.md', '.txt', '.js', '.ts', '.html', '.css', '.c', '.cpp', '.h', '.java', '.rs', '.go', '.json', '.yml', '.yaml'}
|
| 84 |
+
if any(filename.lower().endswith(ext) for ext in text_extensions):
|
| 85 |
+
with z.open(filename) as f:
|
| 86 |
+
total_count += count_em_dashes_in_bytes(f.read(), filename)
|
| 87 |
+
processed = True
|
| 88 |
+
except Exception:
|
| 89 |
+
pass
|
| 90 |
+
else:
|
| 91 |
+
# Handle as single file URL
|
| 92 |
+
try:
|
| 93 |
+
response = requests.get(url, timeout=20)
|
| 94 |
+
if response.status_code == 200:
|
| 95 |
+
filename = url.split('/')[-1] or "file.txt"
|
| 96 |
+
total_count += count_em_dashes_in_bytes(response.content, filename)
|
| 97 |
+
processed = True
|
| 98 |
+
except Exception:
|
| 99 |
+
pass
|
| 100 |
+
|
| 101 |
+
if not processed:
|
| 102 |
+
return "I could not find anything to count! Provide a valid URL or upload a file! Ah ah ah!", gr.update(visible=False)
|
| 103 |
+
|
| 104 |
+
return get_count_response(total_count), gr.update(visible=True)
|
| 105 |
+
|
| 106 |
+
# Define custom CSS for a Sesame Street / The Count theme
|
| 107 |
+
custom_css = """
|
| 108 |
+
body, .gradio-container { background-color: #000000 !important; color: #e0e0e0 !important; font-family: 'Georgia', serif !important; }
|
| 109 |
+
.gr-box { background-color: #1a0633 !important; border: 2px solid #4b0082 !important; }
|
| 110 |
+
#large-input textarea, #large-input input {
|
| 111 |
+
background-color: #2b0b4d !important;
|
| 112 |
+
color: #ffffff !important;
|
| 113 |
+
font-size: 1.5rem !important;
|
| 114 |
+
border: 2px solid #9932cc !important;
|
| 115 |
+
}
|
| 116 |
+
#large-output textarea, #large-output input {
|
| 117 |
+
background-color: #000000 !important;
|
| 118 |
+
color: #32cd32 !important;
|
| 119 |
+
font-size: 1.8rem !important;
|
| 120 |
+
font-weight: bold !important;
|
| 121 |
+
border: 3px solid #32cd32 !important;
|
| 122 |
+
text-shadow: 2px 2px #1a0633;
|
| 123 |
+
}
|
| 124 |
+
#large-button {
|
| 125 |
+
background-color: #4b0082 !important;
|
| 126 |
+
color: #32cd32 !important;
|
| 127 |
+
font-size: 1.6rem !important;
|
| 128 |
+
font-weight: bold !important;
|
| 129 |
+
border: 4px solid #32cd32 !important;
|
| 130 |
+
height: 80px !important;
|
| 131 |
+
box-shadow: 0 0 10px #4b0082;
|
| 132 |
+
transition: all 0.3s ease;
|
| 133 |
+
cursor: pointer;
|
| 134 |
+
}
|
| 135 |
+
#large-button:hover {
|
| 136 |
+
background-color: #9932cc !important;
|
| 137 |
+
color: #ffffff !important;
|
| 138 |
+
box-shadow: 0 0 20px #32cd32;
|
| 139 |
+
transform: scale(1.02);
|
| 140 |
+
}
|
| 141 |
+
.gr-form label span {
|
| 142 |
+
font-size: 1.4rem !important;
|
| 143 |
+
color: #9932cc !important;
|
| 144 |
+
font-weight: bold !important;
|
| 145 |
+
text-transform: uppercase;
|
| 146 |
+
letter-spacing: 2px;
|
| 147 |
+
}
|
| 148 |
+
h1 { color: #9932cc !important; text-shadow: 2px 2px #000000 !important; font-size: 3rem !important; text-align: center !important; }
|
| 149 |
+
h3 { color: #e0e0e0 !important; text-align: center !important; margin-bottom: 2rem !important; }
|
| 150 |
+
.file-upload { background-color: #2b0b4d !important; border: 2px dashed #9932cc !important; }
|
| 151 |
+
"""
|
| 152 |
+
|
| 153 |
+
with gr.Blocks(title="The Count's Em Dash Counter") as demo:
|
| 154 |
+
gr.Markdown("# π§ββοΈ The Count's Em Dash Counter")
|
| 155 |
+
gr.Markdown("### Provide a GitHub repo, a file URL, or upload documents to count em dashes (β)! Ah ah ah!")
|
| 156 |
+
|
| 157 |
+
with gr.Row():
|
| 158 |
+
with gr.Column(scale=4):
|
| 159 |
+
repo_url = gr.Textbox(
|
| 160 |
+
label="GitHub or File URL",
|
| 161 |
+
placeholder="https://github.com/... OR https://example.com/file.pdf",
|
| 162 |
+
lines=1,
|
| 163 |
+
elem_id="large-input"
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
file_upload = gr.File(
|
| 167 |
+
label="Upload Documents (PDF, TXT, MD...)",
|
| 168 |
+
file_types=[".pdf", ".txt", ".md", ".py", ".js", ".ts", ".html", ".css", ".json"],
|
| 169 |
+
elem_classes="file-upload"
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
count_btn = gr.Button("Count them! Ah ah ah!", variant="primary", elem_id="large-button")
|
| 173 |
+
result_text = gr.Textbox(
|
| 174 |
+
label="The Count Says:",
|
| 175 |
+
interactive=False,
|
| 176 |
+
elem_id="large-output",
|
| 177 |
+
lines=3
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
with gr.Column(scale=5):
|
| 181 |
+
video = gr.Video(
|
| 182 |
+
value=VIDEO_URL,
|
| 183 |
+
label="The Count",
|
| 184 |
+
autoplay=True,
|
| 185 |
+
loop=True,
|
| 186 |
+
show_label=False,
|
| 187 |
+
interactive=False,
|
| 188 |
+
visible=False
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
count_btn.click(
|
| 192 |
+
fn=process_input,
|
| 193 |
+
inputs=[repo_url, file_upload],
|
| 194 |
+
outputs=[result_text, video]
|
| 195 |
+
)
|
| 196 |
+
|
| 197 |
+
if __name__ == "__main__":
|
| 198 |
+
demo.launch(css=custom_css, ssr_mode=False)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
gradio==6.14.0
|
| 2 |
-
requests
|
| 3 |
-
pypdf
|
|
|
|
| 1 |
+
gradio==6.14.0
|
| 2 |
+
requests
|
| 3 |
+
pypdf
|