efengx commited on
Commit
5668d9d
·
1 Parent(s): 2192aff

fix: first submit

Browse files
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Rjx Image Identification
3
  emoji: 🐨
4
  colorFrom: yellow
5
  colorTo: blue
@@ -9,5 +9,4 @@ app_file: app.py
9
  pinned: false
10
  license: apache-2.0
11
  ---
12
-
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Rjxai Image Identification
3
  emoji: 🐨
4
  colorFrom: yellow
5
  colorTo: blue
 
9
  pinned: false
10
  license: apache-2.0
11
  ---
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from fengxai.responsive import setModel, getModel, updateModel, applyBindingController
3
+
4
+ ## model
5
+ setModel("distance", 30.07) # (英尺/米)到物体的距离
6
+ setModel("sensorHeight", 24) # (毫米)传感器高度
7
+ setModel("imageObjectHeight", 2724)# (像素)图像中物体的高度
8
+ setModel("lensFocalLength", 60) # (像素)镜头焦距
9
+ setModel("imageHeight", 4912) # (像素)图片的高度
10
+ ## and controller
11
+ updateModel(
12
+ "objectHeight",
13
+ getModel("sensorHeight") * getModel("imageObjectHeight") * getModel("distance") / (getModel("lensFocalLength") * getModel("imageHeight"))
14
+ ) # 物体高度
15
+
16
+ ## view: side 左侧边栏
17
+ def render():
18
+ st.set_page_config(layout="wide")
19
+
20
+ with st.sidebar:
21
+ st.title("example")
22
+ st.image("assets/e1.png")
23
+
24
+ st.title("Rjxai v4_1: :blue[Get object height]")
25
+
26
+ col1, col2 = st.columns(2)
27
+ with col1.container():
28
+ st.title("Input:")
29
+ st.number_input('(feet or meters) distance', key="distance")
30
+ st.number_input('(pixels) image height', key="imageHeight")
31
+ st.number_input('(pixels) image object height', key="imageObjectHeight")
32
+ st.number_input('(mm) sensor height', key="sensorHeight")
33
+ st.number_input('(mm) lens focal length', key="lensFocalLength")
34
+
35
+ with col2:
36
+ st.title("Output:")
37
+ st.text_area("(feet or meters) object height:", key="objectHeight", disabled=True)
38
+
39
+ # control 绑定
40
+ applyBindingController(render)
assets/e1.png ADDED
fengx_launch.ipynb ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "# 任务:配置venv环境\n",
10
+ "!python -m venv .venv\n",
11
+ "!source ../.venv/bin/activate"
12
+ ]
13
+ },
14
+ {
15
+ "cell_type": "code",
16
+ "execution_count": null,
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "# 任务:安装依赖\n",
21
+ "%pip install streamlit"
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "code",
26
+ "execution_count": 6,
27
+ "metadata": {},
28
+ "outputs": [],
29
+ "source": [
30
+ "# 任务:运行本地debug\n",
31
+ "!streamlit run app.py"
32
+ ]
33
+ }
34
+ ],
35
+ "metadata": {
36
+ "kernelspec": {
37
+ "display_name": ".venv",
38
+ "language": "python",
39
+ "name": "python3"
40
+ },
41
+ "language_info": {
42
+ "codemirror_mode": {
43
+ "name": "ipython",
44
+ "version": 3
45
+ },
46
+ "file_extension": ".py",
47
+ "mimetype": "text/x-python",
48
+ "name": "python",
49
+ "nbconvert_exporter": "python",
50
+ "pygments_lexer": "ipython3",
51
+ "version": "3.8.17"
52
+ },
53
+ "orig_nbformat": 4
54
+ },
55
+ "nbformat": 4,
56
+ "nbformat_minor": 2
57
+ }
fengxai/__pycache__/model.cpython-38.pyc ADDED
Binary file (387 Bytes). View file
 
fengxai/__pycache__/responsive.cpython-38.pyc ADDED
Binary file (795 Bytes). View file
 
fengxai/responsive.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # viewModel
2
+ import streamlit as st
3
+
4
+ # model
5
+ def setModel(key, defaultValue=""):
6
+ if key not in st.session_state:
7
+ st.session_state[key]=defaultValue if defaultValue else ""
8
+
9
+ def getModel(key):
10
+ return st.session_state[key]
11
+
12
+ def updateModel(key, value=""):
13
+ setModel(key, value)
14
+ st.session_state[key]=str(value) if value else ""
15
+
16
+ # controller
17
+ def applyBindingController(render):
18
+ render()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ streamlit
2
+ opencv-python-headless
3
+ numpy
4
+ easyocr
5
+ Pillow
6
+ st_clickable_images