import streamlit as st
from streamlit_extras.switch_page_button import switch_page

st.title("RT-DETR")

st.success("""[Original tweet](https://twitter.com/mervenoyann/status/1807790959884665029) (July 1, 2024)""", icon="ℹī¸")
st.markdown(""" """)

st.markdown("""Real-time DEtection Transformer (RT-DETR) landed in 🤗 Transformers with Apache 2.0 license 😍  
Do DETRs Beat YOLOs on Real-time Object Detection? Keep reading 👀  
""")
st.markdown(""" """)

st.video("pages/RT-DETR/video_1.mp4", format="video/mp4")
st.markdown(""" """)

st.markdown("""
Short answer, it does! 📖 [notebook](https://t.co/NNRpG9cAEa), 🔖 [models](https://t.co/ctwWQqNcEt), 🔖 [demo](https://t.co/VrmDDDjoNw)  

YOLO models are known to be super fast for real-time computer vision, but they have a downside with being volatile to NMS đŸĨ˛  
Transformer-based models on the other hand are computationally not as efficient đŸĨ˛  
Isn't there something in between? Enter RT-DETR!  

The authors combined CNN backbone, multi-stage hybrid decoder (combining convs and attn) with a transformer decoder ⇓  
""")
st.markdown(""" """)

st.image("pages/RT-DETR/image_1.jpg", use_column_width=True)
st.markdown(""" """)

st.markdown("""
In the paper, authors also claim one can adjust speed by changing decoder layers without retraining altogether.  
They also conduct many ablation studies and try different decoders.
""")
st.markdown(""" """)

st.image("pages/RT-DETR/image_2.jpg", use_column_width=True)
st.markdown(""" """)

st.markdown("""
The authors find out that the model performs better in terms of speed and accuracy compared to the previous state-of-the-art 🤩
""")
st.markdown(""" """)

st.image("pages/RT-DETR/image_3.jpg", use_column_width=True)
st.markdown(""" """)

st.info("""
Ressources:  
[DETRs Beat YOLOs on Real-time Object Detection](https://arxiv.org/abs/2304.08069) 
by Yian Zhao, Wenyu Lv, Shangliang Xu, Jinman Wei, Guanzhong Wang, Qingqing Dang, Yi Liu, Jie Chen (2023)  
[GitHub](https://github.com/lyuwenyu/RT-DETR/)  
[Hugging Face documentation](https://huggingface.co/docs/transformers/main/en/model_doc/rt_detr)""", icon="📚")

st.markdown(""" """)
st.markdown(""" """)
st.markdown(""" """)
col1, col2, col3 = st.columns(3)
with col1:
    if st.button('Previous paper', use_container_width=True):
        switch_page("4M-21")
with col2:
    if st.button('Home', use_container_width=True):
        switch_page("Home")
with col3:
    if st.button('Next paper', use_container_width=True):
        switch_page("Llava-NeXT-Interleave")