Initial Commit

This commit is contained in:
Amalia Siska Kurniawati 2024-06-14 11:18:28 +07:00
parent ab2131af20
commit 6be3386e84
56 changed files with 5917 additions and 0 deletions

5754
.gitignore vendored Normal file

File diff suppressed because it is too large Load Diff

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

7
.idea/discord.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
</project>

17
.idea/flowpos.iml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/env" />
</content>
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="py.test" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/flowpos.iml" filepath="$PROJECT_DIR$/.idea/flowpos.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

BIN
data/jahe.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

BIN
data/kencur.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
data/kunyit.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

BIN
data/lengkuas.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

BIN
data/temulawak.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
images/636982089.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
images/636982090.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

BIN
images/636982091.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

BIN
images/636982092.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/636982093.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

BIN
images/636982096.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/636982097.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 B

BIN
images/636982098.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1001 B

BIN
images/636982099.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/636982103.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/636982104.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/636982105.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
images/636982106.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

BIN
images/636982107.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/636982109.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/636982110.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/636982111.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/636982112.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

BIN
images/636982114.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/636982116.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

BIN
images/636982117.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

BIN
images/636982118.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/636982119.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

BIN
images/636982120.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/636982121.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
images/636982124.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/636982126.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
images/636982127.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
images/636982128.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/636982129.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/636982130.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/636982133.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

BIN
images/636982185.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

BIN
images/636982186.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

BIN
images/636982208.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

BIN
images/636982209.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

112
main.py Normal file
View File

@ -0,0 +1,112 @@
# bot telegram
import logging
from telegram import Update
from telegram.constants import ParseMode
from telegram.ext import Application, ContextTypes, CommandHandler, MessageHandler, filters
from random import randint
from io import BytesIO
# import openai
import os
# machine learning
from keras.models import load_model
import numpy as np
from keras.preprocessing import image
#fungsi untuk memulai bot
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
# bold
await update.message.reply_text("""
*Selamat datang di medicalplantBot*
medicalplantBot merupakan bot yang dapat membantu anda mengenali tanaman rimpang, tekan /info untuk informasi lebih lanjut""", parse_mode=ParseMode.MARKDOWN_V2)
# Fungsi untuk menampilkan informasi tentang bot
async def info(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text("""Selamat datang di medicalplantBot
Perintah yang tersedia :
- /start untuk memulai bot
- /info untuk informasi mengenai bot
- /show untuk menampilkan contoh gambar tanaman rimpang
Panduan :
kirim sebuah gambar yang sudah dikompresi dalam format JPG untuk mendeteksi jenis tanaman rimpang,
Bot ini dapat mendeteksi 5 jenis tanaman rimpang yaitu :
- Jahe (Zingiber officinale Rosc)
- Kencur (Kaempferia galanga L)
- Kunyit (Curcuma domestica)
- Lengkuas (Alpinia galanga L.)
- Temulawak (Curcuma xanthorrhiza Roxb)
""")
# Fungsi untuk menampilkan contoh gambar tanaman rimpang
async def show(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_photo(open('data/jahe.jpg', 'rb'))
await update.message.reply_text("Jahe (Zingiber officinale Rosc)")
await update.message.reply_photo(open('data/kencur.jpg', 'rb'))
await update.message.reply_text("Kencur (Kaempferia galanga L)")
await update.message.reply_photo(open('data/kunyit.jpg', 'rb'))
await update.message.reply_text("Kunyit (Curcuma domestica)")
await update.message.reply_photo(open('data/lengkuas.jpg', 'rb'))
await update.message.reply_text("Lengkuas (Alpinia galanga L.)")
await update.message.reply_photo(open('data/temulawak.jpg', 'rb'))
await update.message.reply_text("Temulawak (Curcuma xanthorrhiza Roxb)")
# Fungsi untuk menyimpan gambar yang dikirim oleh pengguna dan melakukan prediksi dengan model machine learning
async def save(update: Update, context: ContextTypes.DEFAULT_TYPE):
print('test')
chat_id = str(update.update_id)
file_image = await update.message.photo[0].get_file()
file_image = await file_image.download_as_bytearray()
f = BytesIO(file_image)
with open("images/"+chat_id+".jpg", "wb") as fi:
fi.write(f.getbuffer())
await update.message.reply_photo(open("images/"+chat_id+".jpg", "rb"))
# load machine learning model
model = load_model('./model/medicalplant.h5')
# melakukan prediksi dengan model machine learning
test_image = image.load_img("images/"+chat_id+".jpg", target_size=(64, 64))
test_image = image.img_to_array(test_image)
test_image = np.expand_dims(test_image, axis=0)
result = model.predict(test_image)
print(result)
if result[0][0]:
await update.message.reply_text("*Klasifikasi :*\nTanaman JAHE\n\n*Manfaat :*\nMasuk Angin\n\n*Dosis :*\n 1 x 10 g rimpang / hari \n\n*Cara Penggunaan :*\nBahan dibakar sampai harum, memarkan, seduh dengan 1 cangkir air mendidih, diamkan, mendidih, diamkan dapat ditambahkan gula jawa secukupnya dan diminum selagi hangat", parse_mode=ParseMode.MARKDOWN_V2)
elif result[0][1]:
await update.message.reply_text("*Klasifikasi :*\nTanaman KENCUR\n\n*Manfaat :*\n Terkilir\n\n*Dosis :*\n1 x 1 rimpang / hari\n\n*Cara Penggunaan :*\nBahan dihaluskan bersama beras dan air secukupnya, ditempelkan pada bagian yang sakit dan dibiarkan sampai kering", parse_mode=ParseMode.MARKDOWN_V2)
elif result[0][2]:
await update.message.reply_text("*Klasifikasi :*\nTanaman KUNYIT\n\n*Manfaat :*\nSakit Pinggang\n\n*Dosis :*\n1 x 9 g rimpang / hari \n\n*Cara Penggunaan :*\nBahan diparut, ditempelkan pada bagian yang sakit, dan didiamkan sampai kering", parse_mode=ParseMode.MARKDOWN_V2)
elif result[0][3]:
await update.message.reply_text("*Klasifikasi :*\nTanaman LENGKUAS\n\n*Manfaat :*\nPanu \n\n*Dosis :*\n13 x 1 jari rimpang / hari\n\n*Cara Penggunaan :*\nBahan dipotong miring, memarkan hingga berserabut, rendam dalam cuka, digosokkan pada bagian yang sakit", parse_mode=ParseMode.MARKDOWN_V2)
elif result[0][4]:
await update.message.reply_text("*Klasifikasi :* \nTanaman TEMULAWAK \n\n*Manfaat :* \nLetih Lesu \n\n*Dosis :* \n 2 x 25 g rimpang segar / hari, 1 jam sebelum makan \n\n*Cara Penggunaan :* \nBahan dihaluskan atau diiris, direbus dengan 3 gelas air hingga menjadi 1 gelas, dinginkan, saring dan diminum", parse_mode=ParseMode.MARKDOWN_V2)
else:
await update.message.reply_text("Gambar tidak dapat diketahui")
# Fungsi untuk menangani pesan yang tidak diketahui
async def unknown(update: Update, context: ContextTypes.DEFAULT_TYPE):
input = await update.message.reply_text(update.message.text)
await update.message.reply_text(
"Maaf, perintah '%s' tidak diketaui" % update.message.text)
# Fungsi utama untuk menjalankan bot
def main() -> None:
application = Application.builder().token("6744005884:AAGxQQvz1yilBtAEvP2FYNU771wsGn7zcBk").build()
# command bot
application.add_handler(CommandHandler("start", start))
application.add_handler(CommandHandler("info", info))
application.add_handler(CommandHandler("show", show))
application.add_handler(MessageHandler(filters.TEXT, unknown))
# add Message Handler
application.add_handler(MessageHandler(filters.PHOTO, save))
# run bot
application.run_polling(allowed_updates=Update.ALL_TYPES)
if __name__ == "__main__":
main()

BIN
model/medicalplant.h5 Normal file

Binary file not shown.

BIN
model/medicalplantsBot.h5 Normal file

Binary file not shown.

BIN
model/rhizomes.h5 Normal file

Binary file not shown.

BIN
model/test.h5 Normal file

Binary file not shown.

BIN
model/try.h5 Normal file

Binary file not shown.

BIN
requirements.txt Normal file

Binary file not shown.