Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import leafmap.foliumap as leafmap | |
| import whitebox | |
| st.set_page_config(layout="wide") | |
| st.sidebar.info( | |
| """ | |
| - Web App URL: <https://interactive-crime-map.hf.space/> | |
| - HuggingFace repository: <https://huggingface.co/spaces/interactive-crime/map/tree/main> | |
| """ | |
| ) | |
| st.sidebar.title("Contact") | |
| st.sidebar.info( | |
| """ | |
| Yunus Serhat Bıçakçı at [yunusserhat.com](https://yunusserhat.com) | [GitHub](https://github.com/yunusserhat) | [Twitter](https://twitter.com/yunusserhat) | [LinkedIn](https://www.linkedin.com/in/yunusserhat) | |
| """ | |
| ) | |
| st.title("Hate Speech Interactive Map Application") | |
| please_note = '<p style="color:Red; font-weight:bold;">Please note that the information displayed may contain sentences containing hateful content. Kindly keep this in mind before reviewing the details.</p>' | |
| st.markdown( | |
| """ | |
| The interactive map illustrate a hate crime tweets in London boroughs for the month of December 2022. Model 1 is the latest model from [TweetNLP](https://arxiv.org/pdf/2206.14774.pdf) and [CardiffNLP](https://huggingface.co/cardiffnlp/twitter-roberta-base-hate-multiclass-latest), and Model 2 is an older version of Model 1, owned by [Dimosthenis Antypas](https://huggingface.co/antypasd/). Both models have been utilized for hate speech detection. | |
| """ | |
| ) | |
| st.markdown(please_note, unsafe_allow_html=True) | |
| st.markdown( | |
| """ | |
| """ | |
| ) | |
| # add whitebox tools to the map | |
| m = leafmap.Map(center=[51.50, -0.1], zoom=10) | |
| tweets2 = 'https://raw.githubusercontent.com/yunusserhat/data/main/data/London2022DecHateTweetsLatLong.csv' | |
| borough2 = 'https://raw.githubusercontent.com/yunusserhat/data/main/data/londonborough.geojson' | |
| tweets = 'https://raw.githubusercontent.com/yunusserhat/data/main/data/multiclass_latest_latlng.csv' | |
| borough = 'https://raw.githubusercontent.com/yunusserhat/data/main/data/londonborough.geojson' | |
| map_option = st.selectbox('Choose a Map', ('Model 1', 'Model 2')) | |
| #palette_model_1 = ["red", "blue", "green", "yellow", "purple", "orange"] | |
| #palette_model_2 = ["red", "blue", "green", "yellow", "purple"] | |
| if map_option == 'Model 1': | |
| m.add_geojson(borough, layer_name='London Boroughs') | |
| m.add_points_from_xy( | |
| tweets, | |
| x="Longitude", | |
| y="Latitude", | |
| color_column='Hate Prediction', | |
| palette="RedYellowBlue_11", | |
| spin=True, | |
| add_legend=True | |
| ) | |
| else: | |
| m.add_geojson(borough2, layer_name='London Boroughs 2') | |
| m.add_points_from_xy( | |
| tweets2, | |
| x="Longitude", | |
| y="Latitude", | |
| color_column='Hate Prediction', | |
| palette="GreenMagenta_16", | |
| spin=True, | |
| add_legend=True | |
| ) | |
| m.to_streamlit() | |