anycoder-0aaaebb9 / utils.py
akhaliq's picture
akhaliq HF Staff
Upload folder using huggingface_hub
c5840db verified
raw
history blame
475 Bytes
import re
def parse_resolution(resolution_str):
"""Parse resolution string into width and height"""
match = re.search(r"(\d+)\s*[×x]\s*(\d+)", resolution_str)
if match:
return int(match.group(1))), int(match.group(2)))
return 1024, 1024 # Default fallback
def clean_model_output(text):
"""Clean model output for display"""
text = re.sub(r"```.*?```", "", text, flags=re.DOTALL)
text = re.sub(r"\n+", "\n", text).strip()
return text